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;
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%';
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%';
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)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.