Premium

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



Question : Due to growth within the area code, the telephone exchange is being reassigned to the area code.
The data set Clients.Piedmont includes the variable Phone, which contains telephone numbers in the form 919-555-1234.
Which of the following programs will correctly change the values of Phone?
 :  Due to growth within the  area code, the telephone exchange  is being reassigned to the  area code.
1. data work.piedmont(drop=areacode exchange);
set clients.piedmont;
Areacode=substr(phone,1,3);
Exchange=substr(phone,5,3);
if areacode='919' and exchange='555'
then scan(phone,1,3)='920';
run;
2. data work.piedmont(drop=areacode exchange);
set clients.piedmont;
Areacode=substr(phone,1,3);
Exchange=substr(phone,5,3);
if areacode='919' and exchange='555'
then phone=scan('920',1,3);
run;
3. data work.piedmont(drop=areacode exchange);
set clients.piedmont;
Areacode=substr(phone,1,3);
Exchange=substr(phone,5,3);
if areacode='919' and exchange='555'
then substr(phone,5,3)='920';
run;
4. data work.piedmont(drop=areacode exchange);
set clients.piedmont;
Areacode=substr(phone,1,3);
Exchange=substr(phone,5,3);
if areacode='919' and exchange='555'
then phone=substr('920',1,3);
run;

Correct Answer : 3


The SUBSTR function replaces variable values if it is placed on the left side of an assignment statement. When placed on the right side (Read explanation from Question ), the
function extracts a substring




Question : Suppose you need to create the variable FullName by concatenating the values of FirstName,
which contains first names, and LastName, which contains last names. What's the best way to remove extra blanks between first names and last names?

The SUBSTR function replaces variable values if it is placed on the left side of an assignment statement. When placed on the right side (Read explanation from  ), the
1. data work.maillist;
set retail.maillist;
length FullName $ 40;
fullname=trim firstname||' '||lastname;
run;
2. data work.maillist;
set retail.maillist;
length FullName $ 40;
fullname=trim(firstname)||' '||lastname;
run;
3. data work.maillist;
set retail.maillist;
length FullName $ 40;
fullname=trim(firstname)||' '||trim(lastname);
run;
4. data work.maillist;
set retail.maillist;
length FullName $ 40;
fullname=trim(firstname||' '||lastname);
run;

Correct Answer : 2


Explanation: The TRIM function removes trailing blanks from character values. In this case, extra blanks must be removed from the values of FirstName. Although answer c also works, the
extra TRIM function for the variable LastName is unnecessary. Because of the LENGTH statement, all values of FullName are padded to 40 characters.





Question :
The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigned a permanent label of "Asking Price".
Which SAS program temporarily replaces the label "Asking Price" with the label "Sale Price" in the output?
 :
1. proc print data = sasuser.houses; label price = "Sale Price"; run;
2. proc print data = sasuser.houses label; label price "Sale Price"; run;
3. proc print data = sasuser.houses label; label price = "Sale Price"; run;
4. proc print data = sasuser.houses; price = "Sale Price"; run;


Correct Answer : 3
SAS variables can have these attributes:
name
type
length
informat
format
label
position in observation
index type
Two variable attributes, format and label, affect how variable values and names are represented when they are printed or displayed. These attributes are assigned with different
statements

In procedure output, SAS automatically writes the variables with the names that you specify. However, you can designate a label for some or all of your variables by specifying a
LABEL statement either in the DATA step or, with some procedures, in the PROC step of your program. Your label can be up to 256 characters long, including blanks.

In procedure output, SAS automatically writes the variables with the names that you specify. However, you can designate a label for some or all of your variables by specifying a
LABEL statement either in the DATA step or, with some procedures, in the PROC step of your program. Your label can be up to 256 characters long, including blanks.
If you specify the LABEL statement in the DATA step, the label is permanently stored in the data set. If you specify the LABEL statement in the PROC step, the label is associated
with the variable only for the duration of the PROC step. In either case, when a label is assigned, it is written with almost all SAS procedures. The exception is the PRINT
procedure. Whether you put the LABEL statement in the DATA step or in the PROC step, with the PRINT procedure you must specify the LABEL option as follows:
proc print data=report label;
run;


Related Questions


Question : The following SAS program is submitted:
data _null_;
set old (keep = prod sales1 sales2);
file 'file-specification';
put sales1 sales2;
run;
Which one of the following default delimiters separates the fields in the raw data file created?

 : 	The following SAS program is submitted:
1. : (colon)
2. (space)
3. Access Mostly Uused Products by 50000+ Subscribers
4. ; (semicolon)


Question :

The contents of the raw data file TEAM are listed below:
--------10-------20-------30
Janice 10
Henri 11
Michael 11
Susan 12
The following SAS program is submitted:
data group;
infile 'team';
input name $15. age 2.;
file 'file-specification';
put name $15. +5 age 2.;
run;
Which one of the following describes the output created?


 :
1. a raw data file only
2. a SAS data set named GROUP only
3. Access Mostly Uused Products by 50000+ Subscribers
4. No output is generated as the program fails to execute due to errors.


Question :The contents of the SAS data set named PERM.STUDENTS are listed below:
name age
Alfred 14
Alice 13
Barbara 13
Carol 14
The following SAS program is submitted using the PERM.STUDENTS data set as input:
libname perm 'SAS-data-library';
data students;
set perm.students;
file 'file-specification';
put name $15. @5 age 2.;
run;
Which one of the following represents the values written to the output raw data file?
 :The contents of the SAS data set named PERM.STUDENTS are listed below:
1.
--------10-------20-------30
Alfred 14
Alice 13
Barbara 13
Carol 14
2.
--------10-------20-------30
Alfr14
Alic13
Barb13a
Caro14
3. Access Mostly Uused Products by 50000+ Subscribers
--------10-------20-------30
Alfr14ed
Alic13e
Barb13ara
Caro14l
4.
--------10-------20-------30
Alfred 14
Alice 13
Barbara 13
Carol 14


Question :

The contents of the SAS data set PERM.JAN_SALES are listed below:
VARIABLE NAME TYPE
idnum character variable
sales_date numeric date value
A comma delimited raw data file needs to be created from the PERM.JAN_SALES data set. The SALES_DATE values need to be in
a MMDDYY10 form.
Which one of the following SAS DATA steps correctly creates this raw data file?

 :
1. libname perm 'SAS-data-library';
data _null_;
set perm.jan_sales;
file 'file-specification' dsd = ',';
put idnum sales_date : mmddyy10.;
run;
2. libname perm 'SAS-data-library';
data _null_;
set perm.jan_sales;
file 'file-specification' dlm = ',';
put idnum sales_date : mmddyy10.;
run;
3. Access Mostly Uused Products by 50000+ Subscribers
data _null_;
set perm.jan_sales;
file 'file-specification';
put idnum sales_date : mmddyy10. dlm = ',';
run;
4. libname perm 'SAS-data-library';
data _null_;
set perm.jan_sales;
file 'file-specification';
put idnum sales_date : mmddyy10. dsd = ',';
run;


Question : A raw data record is shown below:
07Jan2002
Which one of the following informats would read this value and store it as a SAS date value?
 : A raw data record is shown below:
1. date9
2. ddmonyy9
3. Access Mostly Uused Products by 50000+ Subscribers
4. ddmmmyyyy9


Question : The following SAS program is submitted:
libname temp 'SAS-data-library';
data work.new;
set temp.jobs;
format newdate mmddyy10.;
qdate = qtr(newdate);
ddate = weekday(newdate);
run;
proc print data = work.new;
run;
The variable NEWDATE contains the SAS date value for April 15, 2000.
What output is produced if April 15, 2000 falls on a Saturday?
 : The following SAS program is submitted:
1. Obs newdate qdate ddate
1 APR152000 2 6
2. Obs newdate qdate ddate
1 04/15/2000 2 6
3. Access Mostly Uused Products by 50000+ Subscribers
1 APR152000 2 7
4. Obs newdate qdate ddate
1 04/15/2000 2 7