BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
margi123
Fluorite | Level 6
Question 1) Can you please explain me with its answer? 
 
Given the raw data file EMPLOYEE:
----I----1 0---I----20---I----30
Ruth 39 11
Jose 32 22
Sue 30 33
24 SAS Institute A00-211 Exam
John 40 44
The following SAS program is submitted:
data test;
infile `employee';
input employee_name $ 1-4;
if employee_name = `Ruth' then input idnum 10-11;
else input age 7-8;
run;
What value does the variable IDNUM contain when the name of the employee is "Ruth"?
A. 11
B. 22
C. 33
D. (missing numeric value)
 
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Run the code.

Read the log.

 

IF the code you have pasted is what you actually run you should have errors like this:

162  infile `employee';.
            -        ---
            22       23
            200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

Note that the _ is under a character that looks like this: `

If you enter code into the editor and use the key to the right of the one with : you will get '   if you use the one in the upper left of the keyboard you get `  They are not the same character. SAS expects '  or " to surround character values.

the same thing happens with `Ruth'   you can see that the mark before the R is not the same as the one at the end.

 

Notice the code box with the log result. If I paste the same thing into the main body:

162 infile `employee';.

- ---

22 23

200

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

 

and we cannot see where the _ is indicating the error because the message board reformatted the text from the log.

 

There is another possible issue with the INFILE statement. If you use: Infile 'employee'; SAS will look for the file from the location that SAS is currently running which is very likely not to be where the file is located. You should specify a fully qualified path, which is operating system dependent, to the file. That different operating systems use different path structures is likely ignored for this test problem to make the question non-operating system dependent.

 

View solution in original post

3 REPLIES 3
ballardw
Super User

Run the code.

Read the log.

 

IF the code you have pasted is what you actually run you should have errors like this:

162  infile `employee';.
            -        ---
            22       23
            200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

Note that the _ is under a character that looks like this: `

If you enter code into the editor and use the key to the right of the one with : you will get '   if you use the one in the upper left of the keyboard you get `  They are not the same character. SAS expects '  or " to surround character values.

the same thing happens with `Ruth'   you can see that the mark before the R is not the same as the one at the end.

 

Notice the code box with the log result. If I paste the same thing into the main body:

162 infile `employee';.

- ---

22 23

200

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

 

and we cannot see where the _ is indicating the error because the message board reformatted the text from the log.

 

There is another possible issue with the INFILE statement. If you use: Infile 'employee'; SAS will look for the file from the location that SAS is currently running which is very likely not to be where the file is located. You should specify a fully qualified path, which is operating system dependent, to the file. That different operating systems use different path structures is likely ignored for this test problem to make the question non-operating system dependent.

 

margi123
Fluorite | Level 6
In this question the answer is comes 22 but i do know how its come.

I think that the answer should come 11
Ksharp
Super User
input employee_name $ 1-4;

there is not @ at the end of it. So the point will go to the next line ,
therefore you will get 22.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1373 views
  • 2 likes
  • 3 in conversation