Premium

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



Question : Suppose the YEARCUTOFF= system option is set to . Which MDY function creates the date value for January , ?

 :  Suppose the YEARCUTOFF= system option is set to . Which MDY function creates the date value for January , ?
1. MDY(1,5,14)
2. MDY(5,1,14)
3. MDY(1,5,2014)
4. MDY(5,1,2014)


Correct Answer : 3


Explanation: Because the YEARCUTOFF= system option is set to 1920, SAS sees the two-digit year value 20 as 1920. Four-digit year values are always read correctly.
Syntax :MDY(month,day,year)
Required Arguments
month : specifies a numeric constant, variable, or expression that represents an integer from 1 through 12.
day : specifies a numeric constant, variable, or expression that represents an integer from 1 through 31.
year : specifies a numeric constant, variable, or expression with a value of a two-digit or four-digit integer that represents the year. The YEARCUTOFF= system option defines the
year value for two-digit dates.

Example
The following SAS statements produce these results.

SAS Statement

birthday=mdy(8,27,90);
put birthday;
put birthday= worddate.;

Result

birthday=August 27, 1990

SAS Statement
anniversary=mdy(7,11,2001);
put anniversary;
put anniversary=date9.;

Result
anniversary=11JUL2001







Question : The variable Address contains values such as Newdelhidl, DL. How do you assign the two-letter state abbreviations to a new variable named Capital?
 :  The variable Address contains values such as Newdelhidl, DL. How do you assign the two-letter state abbreviations to a new variable named Capital?
1. Capital=scan(address2,2);
2. Capital=scan(address2,13,2);
3. Capital=substr(address2,2);
4. Capital=substr(address2,13,2);

Correct Answer : 1

The SCAN function is used to extract words from a character value when you know the order of the words, when their position varies, and when the words are marked by some delimiter.
In this case, you don't need to specify delimiters, because the blank and the comma are default delimiters.

Syntax SCAN(string, count(,charlist (,modifiers) ) )
Required Arguments
string : specifies a character constant, variable, or expression.
count : is a nonzero numeric constant, variable, or expression that has an integer value that specifies the number of the word in the character string that you want SCAN to select.
For example, a value of 1 indicates the first word, a value of 2 indicates the second word, and so on. The following rules apply:
If count is positive, SCAN counts words from left to right in the character string.
If count is negative, SCAN counts words from right to left in the character string.

Optional Arguments
charlist : specifies an optional character expression that initializes a list of characters. This list determines which characters are used as the delimiters that separate words. The
following rules apply:
By default, all characters in charlist are used as delimiters.
If you specify the K modifier in the modifier argument, then all characters that are not in charlist are used as delimiters.

Tip:You can add more characters to charlist by using other modifiers.





Question : The variable EmpCode contains values such as FL and MX.
The fourth character identifies sex. How do you assign these character codes to a new variable named MaleORFemale?
 :  The variable EmpCode contains values such as FL and MX.
1. MaleORFemale=scan(empcode,4);
2. MaleORFemale=scan(empcode,4,1);
3. MaleORFemale=substr(empcode,4);
4. MaleORFemale=substr(empcode,4,1);


Correct Answer : 4

The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the position to start from and the number of
characters to extract. Syntax : SUBSTR(variable, position(,length))=characters-to-replace

Required Arguments
variable : specifies a character variable.
position : specifies a numeric constant, variable, or expression that is the beginning character position.
characters-to-replace : specifies a character constant, variable, or expression that will replace the contents of variable.
Tip:Enclose a literal string of characters in quotation marks.

Optional Argument
length : specifies a numeric constant, variable, or expression that is the length of the substring that will be replaced.
Restriction:length cannot be larger than the length of the expression that remains in variable after position.
Tip:If you omit length, SAS uses all of the characters on the right side of the assignment statement to replace the values of variable.
Details : If you use an undeclared variable, it will be assigned a default length of 8 when the SUBSTR function is compiled.
When you use the SUBSTR function on the left side of an assignment statement, SAS replaces the value of variable with the expression on the right side. SUBSTR replaces length
characters starting at the character that you specify in position.

Example : The following SAS statements produce these results.
SAS Statement
a='KIDNAP';
substr(a,1,3)='CAT';
put a;

Result : CATNAP

SAS Statement
b=a;
substr(b,4)='TY';
put b;

Result : CATTY



Related Questions


Question :

The following SAS program is submitted:
proc datasets lib = sasuser;
contents data = class varnum;
quit;
Which one of the following is the purpose of the VARNUM option?

 :
1. to print a list of variable names
2. to print the total number of variables
3. Access Mostly Uused Products by 50000+ Subscribers
4. to print a list of the variables in the order they were created


Question :

The following SAS program is submitted:
proc contents data = sasuser.airplanes;
run;
Which one of the following is produced as output?

 :
1. the data portion of every data set in the SASUSER library
2. the data portion of the data set SASUSER.AIRPLANES only
3. Access Mostly Uused Products by 50000+ Subscribers
4. the descriptor portion of the data set SASUSER.AIRPLANES only


Question : A raw data file is listed below:

--------10-------20-------30
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
The following SAS program is submitted using the raw data file as input:
data work.homework;
infile 'file-specification';
input name $ age height;
if age LE 10;
run;
How many observations will the WORK.HOMEWORK data set contain?

 : A raw data file is listed below:
1. 0
2. 2
3. Access Mostly Uused Products by 50000+ Subscribers
4. No data set is created as the program fails to execute due to errors.



Question :

The SASDATA.BANKS data set has five observations when the following SAS program is submitted:
libname sasdata 'SAS-data-library';
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
How many observations will the ALLOBS data set contain?

 :
1. 5
2. 15
3. Access Mostly Uused Products by 50000+ Subscribers
4. 25


Question :

The SAS data set named COMPANY.PRICES is listed below:
COMPANY.PRICES
prodid price producttype sales returns
K12S 5.10 NETWORK 15 2
B132S 2.34 HARDWARE 300 10
R18KY2 1.29 SOFTWARE 25 5
3KL8BY 6.37 HARDWARE 125 15
DY65DW 5.60 HARDWARE 45 5
DGTY23 4.55 HARDWARE 67 2
The following SAS program is submitted:
libname company 'SAS-data-library';
data hware inter soft;
set company.prices (keep = producttype price);
if price le 5.00;
if producttype = 'HARDWARE' then output HWARE;
else if producttype = 'NETWORK' then output INTER;
else if producttype = 'SOFTWARE' then output SOFT;
run;
How many observations does the HWARE data set contain?

 :
1. 0
2. 2
3. Access Mostly Uused Products by 50000+ Subscribers
4. 6


Question :

The following SAS program is submitted:
data allobs;
set sasdata.origin (firstobs = 75 obs = 499);
run;
The SAS data set SASDATA.ORIGIN contains 1000 observations.
How many observations does the ALLOBS data set contain?

 :
1. 424
2. 425
3. Access Mostly Uused Products by 50000+ Subscribers
4. 1000