When I was doing practice exam, I am confused about several questions, please help me figure it out. Thanks so much!
1. Missing character value are represented with a blank, numeric missing value represent with ‘’.’ Is it right?
2. For this question, I thing the comma should be added in where in statement, but the correct answer does not include it
3. I am confused about the answer of this question
@Jianan_luna wrote:
When I was doing practice exam, I am confused about several questions, please help me figure it out. Thanks so much!
1. Missing character value are represented with a blank, numeric missing value represent with ‘’.’ Is it right?
The default missing character for numeric is "." but can be changed. Character variables that are missing aren't really represented by anything. Some times people with use code like this to test for missing values: if var = ' ' to test for missing, and it will "work", but there is more going and it would be better to use: if missing(var) then ...
2. For this question, I thing the comma should be added in where in statement, but the correct answer does not include it.
Commas are optional to delimit values in an IN clause starting in SAS 9.1 (I think, it has been more that a few years ago).
As for the B choice run this code in your SAS session and read the log:
data junk; position='ABC'; if position='1B' or '2B' or '3B' then put "The value is true"; run;
3. I am confused about the answer of this question
3 has several clues that let you know why B, C and D are incorrect. B would only have results for the variable Petalwidth. You can clearly see from the output in the column labeled Variable that multiple variables have data. Since the output was not grouped by Species in any way then the BY and Class statements, which would produce output grouped by the values of Species, were not used.
Since your installation should have the SASHELP.Iris data set I suggest typing and running all 4 responses and see what you get.
The shown output has the minimum value for SepalLength at 54..
Coupled with no shown BY group indicators or values for Species was the main reason I initially believed A to be "correct".
Running the code locally A produces the same result as shown. Which was the basis for my suggestion of running all the code to see the results.
BY species, or Class Species would have an N of 50 for each species which is much smaller than the N in the results.
1. Missing character values are represented by a blank. You can use quotes without a space or with the space:
if name = "" then ... ;
if name = " " ... ;
You can use the MISSING function. You can subset with the WHERE statement: where Name is missing;. As you noted, there are many ways to search for missing character values.
Missing numerics are represented by the dot or period ( . ) without the quotes.
where Age = . ;
if Weight = . then Category = 'Unknown';
2. C is the only correct answer. You cannot use the IF statement inside a PROC step, so A and D are incorrect. The code in answer B, where position = '1B' or '2B' or '3B';, compares the variable Position to '1B' only. The '2B' and '3B' are not compared to any variable, so they are both treated as a declarative text string, which is always true. When you run the program, you will get all the rows.
proc means data=sashelp.baseball;
class Position;
var nRuns nRBI;
where position = '1B' or '2B' or '3B';
run;
You can rewrite this to include the variable Position before each character string:
proc means data=sashelp.baseball;
class Position;
var nRuns nRBI;
where position = '1B' or position = '2B' or position = '3B';
run;
The above WHERE statement is the same as where position in('1B' '2B '3B'); in answer C. Commas are not necessary between the values, but I use them.
where position in ('1B', '2B, '3B');
3. A is the only correct answer. The output displays all numeric values and the minimum value of SepalLength is 54, as specified by the where SepalLength > 53; statement. The output lists all numeric variables, not just SepalLength, so B is incorrect. The data is not broken into separate tables of the different Species, so C is incorrect. The data is not grouped by Specifies in one table, so D is incorrect.
If you have any content questions, please send email to training@sas.com.
This is a knowledge-sharing community for SAS Certified Professionals and anyone who wants to learn more about becoming SAS Certified. Ask questions and get answers fast. Share with others who are interested in certification and who are studying for certifications.To get the most from your community experience, use these getting-started resources:
Community Do's and Don'ts
How to add SAS syntax to your post
How to get fast, helpful answers
Ready to level-up your skills? Choose your own adventure.