BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pchen002
Obsidian | Level 7

Given the SAS data set EMPLOYEES:
EMPLOYEES
NAME SALARY
-------- ------------
Innis60000
Jolli50000
Ellis55000
Liu45000
The following SAS program is submitted:
proc print data = employees; where name like ‘_i%’;
run;
What is contained in the output?
A. Liu only
B. Innis and Ellis only
C. Innis, Ellis, and Liu only
D. Innis, Jolli, Ellis, and Liu

 

Why is the answer "A"??

I do not actually understand the condition name like '_i%'. Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

There is a reason why Maxim #1 (Read the documentation) is number one.

From http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p0eaz2e63dlj17n1i5z17z3h84vp.htm&docsetVer..., section LIKE Operator:

 

underscore (_)
matches just one character in the value for each underscore character.

 

so there must be exactly one character before the "i", and only Liu satisfies this.

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

There is a reason why Maxim #1 (Read the documentation) is number one.

From http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p0eaz2e63dlj17n1i5z17z3h84vp.htm&docsetVer..., section LIKE Operator:

 

underscore (_)
matches just one character in the value for each underscore character.

 

so there must be exactly one character before the "i", and only Liu satisfies this.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2397 views
  • 1 like
  • 2 in conversation