In: Statistics and Probability
sas questions
What options would you specify to direct a proc print statement to print only observations 5 through 10?
How do you get the last word of a text string? Write a statement to show your answer.
Describe the difference between using proc means and the mean function to compute a mean.
Describe the role of the input and infile statements in a data step that reads an external data file.
Write the SAS code required to write the SAS data set dogs_data (assume in the work library) to an excel file called dogsdatafile.xlsx in a worksheet called Dogs Data
Ans(a)
This statement prints only observations 5 through 10 in data set STUDY:
proc print data=study(firstobs=5 obs=10);
Ans:-
DATA one;
String = ' I am a teacher' ;
lastword = Scan( String, -1, ' ' ) ;
put lastword = ;
run ;
the lastword return teacher
(c) By default Proc Means calculate the summary statistics like N, Mean, Std deviation, Minimum and maximum, Where as Mean function compute only the mean values.
(d) The INFILE statement describes the attributes of the external file containing the raw data that you want the DATA step to read. The INFILE statement can either directly name the external file or it can indirectly point to the external file with a fileref defined with the FILENAME statement or window.
With the INPUT statement, you describe to SAS the structure of your data. An INPUT statement that uses simple list input may be able to read your external file by scanning the data lines for data values if your data values are separated by at least one delimiter such as a space.
And (e)
PROC EXPORT data = dogs_data
OUTFILE = ":C/dogsdatafile.xlsx"
DBMS = .xlsx
SHEET = " Dogs Data"
run;