Free SAS Programming & Syntax Questions and Answers — Questions and Answers
Question 1: What is the purpose of a 'DATA' step in SAS?
- To display results of a procedure.
- To define the format of the output.
- To create datasets and manipulate data. (Correct answer)
- To connect to a database.
Correct answer: To create datasets and manipulate data.
The 'DATA' step is used to create datasets, read and manipulate data in SAS.
Question 2: Which of the following is the correct syntax to read in a CSV file in SAS?
- proc import datafile='file.csv';
- data import; infile 'file.csv';
- proc import datafile='file.csv' out=mydata;
- proc import file='file.csv';
This question tests knowledge of how to import CSV files into SAS.
Question 3: How would you create a new variable in a SAS 'DATA' step?
- newvar = oldvar + 10;
- newvar = oldvar;
- newvar = 'value';
- all of the above. (Correct answer)
Correct answer: all of the above.
This question tests knowledge of adding variables in the 'DATA' step.
Question 4: What is the function of 'PROC PRINT' in SAS?
- It performs statistical analysis.
- It prints the contents of a dataset. (Correct answer)
- It sorts the dataset.
- It merges two datasets.
Correct answer: It prints the contents of a dataset.
The 'PROC PRINT' step is used to display the contents of a dataset in SAS.
Question 5: What is the correct way to define a macro variable in SAS?
- %let var = value;
- let var = value;
- var = value;
- %define var = value;
This question tests knowledge of creating macro variables in SAS.
Question 6: Which of the following SAS procedures is used for descriptive statistics?
- PROC MEANS. (Correct answer)
- PROC PRINT.
- PROC SQL.
- PROC UNIVARIATE.
Correct answer: PROC MEANS.
This question checks knowledge of procedures used for descriptive statistics in SAS.
Question 7: What does the 'INFILE' statement do in SAS?
- It specifies where to store the dataset.
- It identifies the external file to read data from. (Correct answer)
- It sorts the input file.
- It merges multiple files.
Correct answer: It identifies the external file to read data from.
The 'INFILE' statement is used to specify the file to read in a 'DATA' step.
Question 8: Which SAS function would you use to compute the mean of a numeric variable?
- MEAN.
- AVG.
- PROC MEANS.
- all of the above. (Correct answer)
Correct answer: all of the above.
This question tests knowledge of statistical functions in SAS.
Question 9: How do you check for missing values in a dataset in SAS?
- Using the 'IS MISSING' function. (Correct answer)
- Using the 'IF' statement.
- Using the 'MISSING' function.
- None of the above.
Correct answer: Using the 'IS MISSING' function.
This question checks knowledge of identifying missing values in a dataset.
What is the purpose of a 'DATA' step in SAS?