17
1. The following is an example of.... (Choose one) data employee; infile 'employee.dat'; /* Assuming directory-based system */ input id $6. name $20. @30 locale $10.; run; A. List B. Column C. Formatted D. Mixed E. Standard 2. True or False...(Choose one) The extesion of ".sas" is required for sas program files. A. True B. False 3. Which of the following are valid statements concerning reading raw data files using list input: (Choose all that apply) A. The DLM= is an option for the infile statement for specifying delimiters. B. All variables have a default length of 8 bytes. C. When the input statement runs into an end-of-line marker, it stops reading data even though there are more fields specified. D. You use a $ after a variable name to specify a character variable. E. Fields are read from left to right. 4. Given the following raw data file, offices.dat, in a directory-based system, which data step would create a SAS data set with one observation for each region: (Choose One) 1 1 2 2 3 3 4 1234567890123456789012345678901234567890 East Maryland Vermont Maine

SAS test

Embed Size (px)

Citation preview

Page 1: SAS test

1. The following is an example of.... (Choose one)

data employee; infile 'employee.dat'; /* Assuming directory-based system */ input id $6. name $20. @30 locale $10.; run; A. ListB. ColumnC. FormattedD. MixedE. Standard

2. True or False...(Choose one)The extesion of ".sas" is required for sas program files.A. TrueB. False

3. Which of the following are valid statements concerning reading raw data files using list input: (Choose all that apply)A. The DLM= is an option for the infile statement for specifying delimiters.B. All variables have a default length of 8 bytes.C. When the input statement runs into an end-of-line marker, it stops reading data even though there are more fields specified.D. You use a $ after a variable name to specify a character variable.E. Fields are read from left to right.

4. Given the following raw data file, offices.dat, in a directory-based system, which data step would create a SAS data set with one observation for each region: (Choose One)

1 1 2 2 3 3 4 1234567890123456789012345678901234567890 East Maryland Vermont Maine Central Illinois Iowa Kansas Missouri West California Washington

A. data offices; infile 'offices.dat' stopover; input region $ state1-state4 $; run;B.data offices; infile 'offices.dat' missover; input region $ (state1-state4) ($);

Page 2: SAS test

run;C.data offices; infile 'offices.dat' delim=" "; input region $ state1 $ state2 $ state3 $ state4 $; run;D.data offices; infile 'offices.dat'; input region $ state1-state4 $.; run;E. None of the above.

5. The double trailing "@@" in an input statement...(Choose all that apply) A. holds the current data line in the buffer for another input statement to processB. can be used to read multiple observations from a single data lineC. loads a new record into the input buffer if an end-of-record is found in the current recordD. is a syntax error.E. None of the above.

6. Which SAS statement below wil change the characteristics of a variable if it was used in a data step? A. SCANB. ATTRIBC. FORMATD. PUTE. ARRAY

7. Which X variable has a value of 1 at the end of an input file?A. END = XB. OBS = XC. EOF = XD. LASTOBS = XE. NOOBS = X

8. Given a data file with 100 columns of data, you only need to read in the first 70 colums. Which of the following could you use:A. infile x line = 70;B. infile x length = 71;C. infile x missover = 70;D. infile x ls=70;E. infile x linesize=70;

Page 3: SAS test

9. In the following code sample:data xyz; infile abc; input h i +3 j; run;What does the +3 do?A. It moves the pointer down 3 recordsB. It moves the column pointer to column 3C. It adds 3 to the value read into variable iD. It advances the column pointer 3 placesE. It advances the column pointer 4 places

10. What does the following SAS statement do?if location =: 'C';A. It selects the observation if there is a 'C' in the location value.B. It selects the observation if there is a 'C' at the first position in the location value.C. It selects the observation if the location value is 'C'.D. It selects the observation if the location value contains a lowercase 'c'.E. None of the above, it's a typo.The following program is submitted. data test;input name $ age;cards;John +35;run;

11. Which values are stored in the output data set? A. name ageJohn 35 B. name ageJohn (missing value)C. name age(missing value) (missing value)D. The DATA step fails execution due to data errors.

12.The following observation is stored in a SAS data set named EMPLOYEES:

LNAME FNAME JOBCODE----------------------------------------------------------------------Whitley Sam na1

If the DATA step below is executed, what will be the value of the variable JOBDESC in the output SAS data set when this observation is processed:

Page 4: SAS test

data navigate;set employees;if jobcode = 'NA1' then jobdesc = 'Navigator';run;A. navigator B. Navigator C. NAVIGATOR D. a missing value

13.The following SAS program is submitted:

proc format;value score 1 - 50 = 'Fail'51 - 100 = 'Pass';run;

Which one of the following PRINT procedure steps correctly applies the format?

A. proc print data = sasuser.class;B. var test;C. format test score;D. run;E. proc print data = sasuser.class;F. var test;G. format test score.;H. run;I. proc print data = sasuser.class format = score;J. var test;K. run;L. proc print data = sasuser.class format = score.;M. var test; N. run;

14 Given the following DATA step: data loop;x = 0;do index = 1 to 5 by 2;x = index ;end;run;

Upon completion of execution, what are the values of the variables X and INDEX in the SAS data set named LOOP? A. x = 3, index = 3 B. x = 3, index = 4

Page 5: SAS test

C. x = 5, index = 5 D. x = 5, index = 6 E. x = 5, index = 7

15 Given that the data set named ONE contains 10 observations and the data set named TWO contains 10 observations, how many observations will be contained in the data set named COMBINE that is created in the following DATA step?

data combine;set one two;run;A. 10 B. 20 C. 0, the DATA step will fail due to syntax errors D. 10 to 20, depending on how many observations match

 

GO TOP

 

 

SAS Practice Test –II

 

1. A format statement should be specified before the CARDS statement when we read internal raw data.a. Trueb. False

2. An external file with a maximum record length of 225 is read into SAS in a DATA step. Select all statements that reads the data correctly.

a. INFILE ‘C:\mydata.dat’ LRECL=2000;b. INFILE ‘C:\mydata.dat’ LRECL=225;c. INFILE ‘C:\mydata.dat’ ;

3. Select the False statement about List Input method of reading dataa. Reads data separated by several spaces.b. Does not skip over unwanted values in the input data.c. Reads a date.

Page 6: SAS test

4. Column Input style can read a character data value with space embeddinga. Trueb. False

5. A standard numeric data in SAS can contain a ‘-‘ (negative) sign and ‘E’ for scientific notationsa. True b. False

6. A non standard data (Numbers with comma, dates like ’03-OCT-2005’ ) can be read with the following INPUT styles (select all correct answers)a. Formatted Inputb. Modified List Inputc. Using Informats in INPUT statement

7. Given the line of raw data:

112233 SCODES Z M N

And the data statement:

INPUT @'SCODES' statuscodes :$10.;

When executed in a DATA step correctly, what value the variable ‘Statuscodes’ gets?

a. Zb. Z M Nc. . (Missing)

 

8. The following statement is submitted:

Data Test;INPUT accnum $ / fname $ lname $ ;cards;12223242 Johny SmithPeter Smith Thomas Joseph ;run;

The output dataset will show which of the following?a. accnum fname lname 12223242 Johny Smith

b. accnum fname lname 12223242 Peter Smith

Page 7: SAS test

c. None of the above

9. The following statement is submitted:Data Test;INPUT accnum $ #2 fname $ lname $ ;cards;12223242 Johny SmithPeter Smith Thomas Joseph ;run;

The output dataset will show which of the following?a. accnum fname lname 12223242 Johny Smith

b. accnum fname lname 12223242 Peter Smithc. None of the above

10. The following INPUT statements are submitted:Data Test;INPUT accnum $ fname $ lname $ @@ ;cards;122232 Johny Smith 132343 Peter Smith 142434 Thomas Joseph;run;

Which of the following statement is correct?

a. Output record set will have only one record b. Output record set will have 3 recordsc. Data step incomplete due to incorrect syntax

 

11. Datafile ‘c:\mydata.dat’ contains account number, first name and last name of account holders with following structure.

122232 Johny Smith142434 Thomas 152535 Dan Paul

Which statement below reads the data correctly into SAS.

a. Data Test;INFILE 'c:\mydata.dat' MISSOVER;INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;run;

Page 8: SAS test

b. Data Test;INFILE 'c:\mydata.dat' TRUNCOVER;INPUT accnum $ 1-6 fname $ 8-14 lname $ 16-20;run;

c. Data Test;INFILE 'c:\mydata.dat' ;INPUT accnum $ fname $ lname $;run;

12. The following statement is submitted

Data Test;INFILE 'c:\mydata.dat’;INPUT client_id $ 1-3 @;IF client_id 'JCP' then delete;INPUT accnum $ 4-8 fname $ 9-14 lname $ 16-20;run;

How many columns will be there in dataset ‘Test’ ?

a. None b. 3c. 4

13. An external data file has account open date in the following format .

01-13-9501-14-9601-15-97

Which of the following is a correct INPUT statement in DATA step to read this data.

a. INPUT Account_no mmddyy8. ;b. INPUT Account_no mmddyy6. ;c. INPUT Account_no ddmmyy8. ;

14. The following statements are submitted

Data Test;today = '20dec2005'd;format today mmddyy10.;run;

Which of the following statement is true ?

Page 9: SAS test

a. ‘Today’ variable displays like ‘12/20/2005’b. Data step not executed due to wrong format ‘mmddyy’.c. Today is displayed as ‘20DEC2005’

15. Following statements are submitted:

proc export data = Account_perf outfile = 'd:\text1.csv';run;

proc export data = Account_perf outfile = 'd:\text2.csv'DBMS =DLM REPLACE;DELIMITER =',';run;

Select all false statements:

a. There are two files , text1.csv and text2.csv , created in d:\ b. Both text1 and text2 files have the same data values delimited by a commac. Text1 data file will have a space-delimited data as a standard SAS output.d. Only text2.csv is created with values delimited by a comma.

GO TOP

SAS Practice Test –III

 

Note: the programs in the example e expects no errors due to improper use of ;, ‘’, ) etc.

1. File C:\mydata.dat contains 100 complete records and the following program is submitted. options obs=10;Data Test;INFILE 'c:\mydata.dat' firstobs=3;INPUT accnum $ fname $ lname $;run;

Which of the following statement is correct?a. Test data set will have 98 rows b. Test dataset will have first 10 observationsc. Test dataset will have 10 observations read starting from third data line in mydata.datd. Test dataset will have 8 observations read starting from third data line in mydata.dat

2. The following program is submitted to read a delimited file

Page 10: SAS test

Data Test;INFILE 'c:\mydata.dat' DLM='$' DSD ;INPUT accnum $ fname $ lname $;run;

What ‘DSD’ keyword does here? (Select all correct answers)

a. It does not treat ‘$’ character as part of the data value and treat it as delimiter.b. It recognize two consecutive ‘$’ characters as a missing value for the variable readc. If data value is specified in quotes with embedded ‘$’ character DSD option treats it as part of the data.

3. A PROC DATATSETS is used as follows(assumption: all libraries are and datasets are existing):

proc datasets library=mylib details;copy out=rloc;select scoredata;delete tension ;run;Which statement below explains the operations above most correctly?

a. It lists all SAS data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library and deletes ‘tension’ dataset..b. It lists all SAS data files with file size and date modified in ‘mylib’ library and deletes ‘tension’ file from ‘rloc’ library.c. It lists all SAS data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library and also copies the ‘scoredata’ file in ‘rloc’ library.d. It lists all sas data files with file size and date modified in ‘mylib’ library and makes a copy of ‘scoredata’ file in ‘rloc’ library.

4. The following program is submitted. Which is a false statement about the output of this program?

proc contents data=scoredata;run;

a. Prints # of observations in ‘scoredata’b. Prints a snapshot of the data into the screen.c. Prints the date ‘scoredata’ was createdd. Lists all labels associated with variables in ‘scoredata’

 

5. The following line of code is used in a SAS data step .

Page 11: SAS test

Data xx;Set yy;attrib status_codes length=$4 label ='Status Codes' format =$upcase8.;run;

If yy has a variable names status_codes and the user wants the attributes to be changed in xx . Will this statement change the length, label and format in xx dataset?

a. YESb. NO c. No Sufficient Information

 

6. The below three program blocks are submitted

A) Data target_data ;Set base_data((keep = var1 var2 var3 );Run;

B) Data target_data ;Set base_data;keep = var1 var2 var3 ;Run;

C) Data target_data (keep = var1 var2 var3 );Set base_data;Run;

If the user needs only var1, var2 and var3 to work with, which step is most efficient?

a. Ab. Bc. Cd. A&Be. None

 

7. The following program is submitted (Assumption is os_dollars is an existing dataset with client groups (client_group) and dollar outstanding (os) fields. ) .

Data test;SET os_dollars END=FIN ;BY client_group;t_os +os;

Page 12: SAS test

IF LAST.clinet_group THEN DO ;g_os +t_os ; t_os=0;END;run;

What this program does?

a. Computes the gross outstanding across the groups and store it in g_os variable, last row.b. Computes the oustandings for client groups and retain them in t_os variablec. None of the above.

 

8. The following program was submitted to SAS data temp;length my_number $ 4;input my_number;cards;12340009;run;

data new(drop=x);set temp(rename=(my_number=x));my_number=input(x,best4.);run;

proc print data=new;run;

What’s the output would be?

A) Obs my_number       1     1234       2     9B) Obs my_number       1    1234       2    0009C) Obs my_number        .       .

9. The following program is submitted:

x='20jan94'd;y=qtr(x);put y=;

What value would be printed to the SAS log?

Page 13: SAS test

a. 1b. 2c. 3d. None

10. The following program submitted:

data xx;date1=122591;date2=put(date1,z6.);run;

What’s the data type of date1 and date 2 ? a. Date1 Character, Date 2 Numericb. Date1 numeric, Date 2 characterc. Syntax error, not executed

 

11. The following statement forms a part of SAS dataset (no syntax errors)

Data xx;Set yy;array weight wt1-wt50;do i=1 to 50;if weight{i}=999 then weight{i}=’missing’;end;run;

Select all correct statements below:

a. Creates a variable weight and assigns w1-wt50 (wt1, wt2, wt3 etc)b. Variables named wt1-wt50 exist in the’ yy’ data set.c. If any of the fields in wt1-wt50 have a value of ‘999’ then it will be reset with a ‘missing’ .d. Evaluated all 50 fields and the entire table looking for value ‘999’ in any of the fields

 

12. The following program is submitted:

proc report data =xx nowindows headline headskip ;Title 'Summary across groups’;column s_g N (os co), MEAN ;define s_g /group;run;

Page 14: SAS test

What’s the objective of using MEAN?

a. Compute mean (Average) of variables OS and COb. Compute mean and N(count) of s_g and MEAN of OS and CO c. Compute mean and N(count) of s_g and MEAN of OS and CO by s_g groups.