Premium

Base SAS Certified Associate: Programming Fundamentals Using SAS Questions and Answers (Dumps and Practice Questions)



Question : The following SAS program is submitted:

proc sort data = work.employee;
by descending fname;
proc sort data = work.salary;
by descending fname;

data work.empdata;
merge work.employee
work.salary;
by fname;
run;

Why does the program rail to execute?

 : The following SAS program is submitted:
1. The SORT procedures contain invalid syntax.
2. The merged data sets are not permanent SAS data sets.
3. Access Mostly Uused Products by 50000+ Subscribers
4. The data sets were not merged in the order by which they were sorted.

Correct Answer : Get Lastest Questions and Answer :

Explanation: You should have the DESCENDING option in the BY statement in both the PROC SORT steps and the DATA STEP. If you omit the DESCENDING option in the DATA STEP, you generate error
messages about improperly sorted BY Variable.

PROC SORT DATA=states;
BY state_name;
PROC SORT DATA=vehicles;
BY state_name;
DATA widedata;
MERGE states vehicles;
BY state_name;
RUN;

You merge data sets using the MERGE statement in a DATA step. The form of the MERGE statement that is used in this section is the following:
MERGE SAS-data-set-list;
BY variable-list;
SAS-data-setlist is the names of two or more SAS data sets to merge. The list may
contain any number of data sets.

variable-list is one or more variables by which to merge the data sets. If you use a BY statement, then the data sets must be sorted by the same BY variables before you can merge them.





Question : The following SAS program is submitted:
data work.sales;
do year = 1 to 5;
do month = 1 to 12;
x + 1;
end;
end;
run;
Which one of the following represents how many observations are written to the WORK.SALES data set?

 : The following SAS program is submitted:
1. 0
2. 1
3. Access Mostly Uused Products by 50000+ Subscribers
4. 60

Correct Answer : Get Lastest Questions and Answer :

Explanation: The output is missing.To write all (12*5) 60 values change syntax to :
.....
x + 1;
*output;
end;
end;
run;

proc print data= work.sales;run;

Or

data work.sales;
do year = 1 to 5;
do month = 1 to 12;
x + 1;
output; end; /*60 with this output statement 'D' */
output; end; /* 5 with this out put statement 'C"*/
run; /* 1 with no output statement 'B' */




Question : Given the following raw data record:
----|----10---|----20---|----30
son Travis,
The following output is desired:
Obs relation firstname
1 son Travis
Which SAS program correctly reads in the raw data?


 : Given the following raw data record:
1. data family ( dIm = `,'); infile `tile specification'; input relation $ firstname $; run;
2. options dIm = `,'; data family; infile `file specification'; input relation $ firstname $; run;
3. Access Mostly Uused Products by 50000+ Subscribers
4. data family; infile `file specification'; input relation $ firstname $ / dim = `,'; run;

Correct Answer : Get Lastest Questions and Answer :

coz.dlm=',' is a infile option

Syntax
INFILE file-specification (device-type) (options) (operating-environment-options);
INFILE DBMS-specifications;

DLM= specifies an alternate delimiter (other than a blank) to be used for LIST input, where delimiter(s) is.




Related Questions


Question :
The following SAS program is submitted: (left image)

What new variables are created?

  :
1. Difcount1, Difcount2 and Difcount3
2. Diff1, Diff2 and Diff3
3. Access Mostly Uused Products by 50000+ Subscribers
4. Patients1, Patients2 and Patients3


Question :
Given the raw data record in the file phone.txt:
Which SAS statement completes the program and results in a value of "James Stevens" for the
variableFullName?

  :
1. FullName=CATX(' ',EmpFName,EmpLName);
2. FullName=CAT(' ',EmpFName,EmpLName);
3. Access Mostly Uused Products by 50000+ Subscribers
4. FullName=EmpFName + EmpLName;


Question :

A realtor has two customers. One customer wants to view a list of homes selling for less than $60,000. The other customer wants
to view a list of homes selling for greater than $100,000.
Assuming the PRICE variable is numeric, which one of the following PRINT procedure steps will select all desired observations?

 :
1. proc print data = sasuser.houses;
where price lt 60000;
where price gt 100000;
run;
2. proc print data = sasuser.houses;
where price lt 60000 or price gt 100000;
run;
3. Access Mostly Uused Products by 50000+ Subscribers
where price lt 60000 and price gt 100000;
run;
4. proc print data = sasuser.houses;
where price lt 60000 or where price gt 100000;
run;
Ans : 2
Exp : 'OR' gives either of one condition whereas we need both condition results , so answer is B. 'OR' means either one of d conditions shd b true. In this case both the
conditions are true, so it will give desired observations. Here if we use 'AND' it will search for the observations in which both the conditions are true at d same time. ie. the
obs where the price is ln 60000 and also the preice is gt100000. Hence answer is not correct.

'OR' means either one of d conditions shd b true. In this case both the conditions are true, so it will give desired observations. Here if we use 'AND' it will search for the
observations in which both the conditions are true at d same time. ie. the obs where the price is ln 60000 and also the preice is gt100000. Hence answer is not correct.




Question : The value is stored in a numeric variable.
Which one of the following SAS formats is used to display the value as $110,700.00 in a report?
 :
1. comma8.2
2. comma11.2
3. Access Mostly Uused Products by 50000+ Subscribers
4. dollar11.2
Ans : 4

Exp : the total width is 11 not 8, so it comes down to either of dollar11.2 or comma11.2. But comma11.2 does not insert dollar sign along with comma. So the answer is 4.

when you use comma11.2 as an informat, sas removes dollar signs, commas and percent signs(if they exist in the value you are trying to read) whereas the format dollar11.2 inserts a
dollar sign and a comma.




Question :
The SAS data set BANKS is listed below:
BANKS
name rate
FirstCapital 0.0718
DirectBank 0.0721
VirtualDirect 0.0728
The following SAS program is submitted:
data newbank;
do year = 1 to 3;
set banks;
capital + 5000;
end;
run;
Which one of the following represents how many observations and variables will exist in the SAS data set NEWBANK?


 :
1. 0 observations and 0 variables
2. 1 observations and 4 variables
3. Access Mostly Uused Products by 50000+ Subscribers
4. 9 observations and 2 variables

Ans : 2
Exp :

The four variables are Name, Rate, Year, Capital. we have three variables in the dataset, when we set the dataset in the do loop it reads the three observations from data set
banks (as the set statement is called thrice) when they do loop terminates the value for year is 4 and the implicit output is executed at run;

this causes the observation to be written in the new data set. since all three observations are read in the the do loop the data step gets terminated and only one observations is
written since we have two additional variables in the data step year and capital we get total of 4 variables




Question :

The following SAS program is submitted:
data work.clients;
calls = 6;
do while (calls le 6);
calls + 1;
end;
run;
Which one of the following is the value of the variable CALLS in the output data set?



 :
1. 4
2. 5
3. Access Mostly Uused Products by 50000+ Subscribers
4. 7
Ans : 4
Exp : Please note the difference between do while and do until:


DO WHILE
The while test is evaluated at the top of the loop.

DO UNTIL
The until test is evaluated at the bottom of the loop.

DO WHILE (evaluates at the top of the loop) Now, calls=6 is equal to 6 therefore calls le 6 is TRUE. DO LOOP is executed. So, calls = calls +1 = 7

Now, calls=7 is greater than 6 therefore calls le 6 is FALSE. DO LOOP is not executed.

Hence, the value of calls remains 7

here, note that the operator is LE (less than or equal to). So the condition is true the first time.
Calls = 6 and it becomes Calls + 1 => 6+1 = 7.

The loop stops executing as the value of calls becomes greater than 6. Thus, output is 7.




Question :

The following SAS program is submitted:
data work.pieces;
do while (n lt 6);
n + 1;
end;
run;
Which one of the following is the value of the variable N in the output data set?



 :
1. 4
2. 5
3. Access Mostly Uused Products by 50000+ Subscribers
4. 7
Ans : 3
Exp : DO WHILE
The while test is evaluated at the top of the loop.

DO UNTIL
The until test is evaluated at the bottom of the loop.


DO WHILE (evaluates at the top of the loop). [Remember: SAS gives value starting from 0, if value not defined] n=0, 1, 2, 3, 4, 5 than n is lt (less than) 6 therefore n lt 6 is TRUE.
DO LOOP is executed.
Adding plus 1 at every iteration.
Now, when n=6 at top, it is not less than 6 therefore condition n lt 6 is FALSE. DO LOOP is not executed.
Hence, the value of n remains 6

because of n+1 statement we assume a implicit retain n 0; statment.
First loop (0 lt 6) => true => n = 1
Second loop (1 lt 6) => true => n= 2
......
last loop (6 lt 6) => false => do while exits and pdv writes 6 as value of n in output dataset.




Question :

Suppose the YEARCUTOFF= system option is set to 1920. An input file contains the date expression 12/08/1925,
which is being read with the MMDDYY8. informat. Which date will appear in your data?


 :
1. 08DEC1920
2. 08DEC1925
3. Access Mostly Uused Products by 50000+ Subscribers
4. 08DEC2025
Ans : 3
Exp : The w value of the informat MMDDYY8. is too small to read the entire value, so the last two digits of the year are truncated. The last two digits thus become 19 instead of 25.
Because the YEARCUTOFF= system option is set to 1920, SAS interprets this year as 2019. To avoid such errors, be sure to specify an informat that is wide enough for your date
expressions



Question :

Suppose your program creates two variables from an input file. Both variables are stored as
SAS date values: FirstDay records the start of a billing cycle, and LastDay records the end of that cycle.
The code for calculating the total number of days in the cycle would be:


 :
1. TotDays=lastday-firstday;
2. TotDays=lastday-firstday+1;
3. Access Mostly Uused Products by 50000+ Subscribers
4. You cannot use date values in calculations.
Ans : 2
Exp : To find the number of days spanned by two dates, subtract the first day from the last day and add one. Because SAS date values are numeric values, they can easily be used in
calculations





Question :

You can position the input pointer on a specific record by using


 :
1. column pointer controls
2. column specifications.
3. Access Mostly Uused Products by 50000+ Subscribers
4. line hold specifiers.

Ans : 3
Exp : Information for one observation can be spread out over several records. You can write one INPUT statement that contains line pointer controls to specify the record(s) from
which values are read.



Question : When you are creating a custom format using FORMAT procedure, than which of the following statement is correct?

 :
1. Format name and Data set name should be same.

2. Format name should be longer the 2 character

3. Access Mostly Uused Products by 50000+ Subscribers

4. Format name should start with the $ sign only in case, it is applied to the character variable

5. Format name should start with the $ sign only in case, it is applied to the character variable



Question : Select the correct defined format from below

 : Select the correct defined format from below
1. proc format lib=library;
value location ;
1='Mumbai'
2='Pune'
3='Chennai';
run;


2. proc format lib=library;
value location
1='Mumbai'
2='Pune'
3='Chennai';
run;


3. Access Mostly Uused Products by 50000+ Subscribers
value location
1='Mumbai'
2='Pune'
3='Chennai'
run;


4. proc format lib=library;
value location ;
1='Mumbai' ;
2='Pune';
3='Chennai';
run;



Question : While creating a user defined formats, what all are possible values?
A. You can use single value like 100 or 'H'
B. You can use the range of values like 0-100
C. You can use character range like 'A'-'G'
D. You can define a list which can contain anything lile 'A' ,100, 200, 'SAS' etc.


 : While creating a user defined formats, what all are possible values?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,B,D


Question : Which pointer control can be used to read records non-sequentially?

  : Which pointer control can be used to read records non-sequentially?
1. @n
2. #n
1. +n
2. /
Ans : 2
Exp : The #n line pointer control is used to read records non-sequentially. The #n specifies the absolute number of the line to which you want to move the pointer.


Question : While creating user defined format and you want to specify particular label for a particular value in data set. What is the maximum
possible character length for a label?

  : Which pointer control can be used to read records non-sequentially?
1. 32

2. 8

3. Access Mostly Uused Products by 50000+ Subscribers

4. 256

5. 32,767