BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nelson12
Calcite | Level 5

What is the value of Common_Names in row one? I encountered this problem and I am not sure I understand what value is required. below is the code. 

libname out "~/EPG1V2/output";
*libname out "~/EPG194/output";

data out.fox;
set pg1.np_species;
where Category='Mammal' and Common_Names like
'%Fox%' and Common_Names not like
'%Squirrel%';
drop Category Record_Status Occurrence Nativeness;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
russt_sas
SAS Employee

Not sure what you mean here.  The percent is a wildcard that says match any character, so your WHERE below is checking to see if the variable COMMON_NAMES contains a string that has Fox or does not contain the string Squirrel.  Using the wildcard means that aFoxb would be accepted.  If this is not what you are looking for, please explain further.

 

where Category='Mammal' and Common_Names like
'%Fox%' and Common_Names not like
'%Squirrel%';

View solution in original post

3 REPLIES 3
russt_sas
SAS Employee

Not sure what you mean here.  The percent is a wildcard that says match any character, so your WHERE below is checking to see if the variable COMMON_NAMES contains a string that has Fox or does not contain the string Squirrel.  Using the wildcard means that aFoxb would be accepted.  If this is not what you are looking for, please explain further.

 

where Category='Mammal' and Common_Names like
'%Fox%' and Common_Names not like
'%Squirrel%';

Nelson12
Calcite | Level 5
I got the point now. Thank You
ballardw
Super User

WE don't have your data set. Even if we did there is a chance that your have sorted the data set. So questions about "row one" are a bit difficult to answer. And row one from the input set or the output data set?

 

The conditions are saying the output values should come from Category='Mammal' (remove category from the Drop statement to see the variable in the output set) with Common_names containing "Fox" and not containing "Squirrel". So you might have values of Common_names like "Red Fox" "Gray Fox"  but should not see "Fox Squirrel" (or "Squirrel Fox")

 

Did you run the code? What did the output look like? (Proc Print data=out.fox;run; if you don't know how to print yet)

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 189 views
  • 0 likes
  • 3 in conversation