Hi all,
I'm a newbie with SAS of just 1 week experience and learning through Coursera and this website. The activity is requesting that in my freq output that I put Species_ID to have results starting with YOSE and Category equal to Mammals.
Errors I'm receiving:
ERROR: Variable Mammal is not on file PG1.NP_SPECIES.
I'm not asking for answers on solving this activity but rather some pointers on what code should be where , Proc FREQ and Proc Print.
Below is my code; (Please be gentle in criticism lol)
proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
run;
proc print data=pg1.np_species;
var Species_ID Category;
where species_id = "YOSE%" and Category = Mammal;
run;
Thanks for everyone's time 🙂
are you missing to include Mammals within quotes " "
proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
run;
proc print data=pg1.np_species;
var Species_ID Category;
where species_id = "YOSE%" and Category = "Mammal";
run;
are you missing to include Mammals within quotes " "
proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
run;
proc print data=pg1.np_species;
var Species_ID Category;
where species_id = "YOSE%" and Category = "Mammal";
run;
Good question. Checking now..
It looks like when I typed out this issue I WAS missing quotation marks but it doesn't seem to have a difference in my results output.
My goal; is to have species_Id show anything starting with YOSE and Category to point to Mammal only..here are my results with and without quotations. It isn't printing what I've got in PROC PRINT.
Does it matter if the Print statement is before or after Proc Freq?
I am going guess here as I do not know what's in your species data. Perhaps, you are after this?
where upcase(species_id) like "YOSE%" and upcase(Category) = "MAMMAL";
/*Task1*/
proc print data=pg1.np_species;
var Species_ID Category;
where upcase(species_id) like "YOSE%" and upcase(Category) = "MAMMAL";
run;
/*Task 2*/
proc freq data=pg1.np_species;
tables Abundance Conservation_Status;
run;
Both responses to this issue are correct, Thanks a TON and it's pretty likely you'll see more posts from me in the future haha but I look forward to getting SAS down . Thanks again for your patience with me
@Cyclopsedia wrote:
Good question. Checking now..
It looks like when I typed out this issue I WAS missing quotation marks but it doesn't seem to have a difference in my results output.
My goal; is to have species_Id show anything starting with YOSE and Category to point to
If you used "YOSE%" as a LIKE value then you have to use Like "YOSE%" not =.
Or you can use the =: comparison for a "starts with"
where species_id =: "YOSE%"
The order for Proc Freq and Proc Print would really matter if you are creating a data set in Proc Freq that you want to print with Proc Print. But with both (or multiple procedures) using the same input data set then the order in the code is the order the results are created. So if you have a preference of appearance then have the procedures in the desired order.
Both responses to this issue are correct, Thanks a TON guys. it's pretty likely you'll see more posts from me in the future haha but I look forward to getting SAS down 🙂
Welcome to SAS communities @Cyclopsedia
Sir @ballardw , I have noticed you sharing a set of instructions that depicts how to ask a good question. Could you please post that here so that OP can use and follow those well laid instructions in the future
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.