Hi, everyone,
I am working through the Programming Essentials class, Lesson 4, first Practice section, Level 2. The code (copied directly from the solution) is:
data fox;
set pg1.np_species;
where Category='Mammal' and upcase(Common_Names) like '%FOX%';
drop Category Record_Status Occurrence Nativeness;
run;
The next step says "Notice that Fox Squirrels are included in the output table." But nothing is showing up in my Output window at all. What's going on here? I'm using the desktop version of SAS.
Thanks.
the dataset would have been created in the work library. did you look in the log and see if the dataset was actually created? otherwise, go to work library and open up fox dataset and examine the contents.
I think so. The log reads:
NOTE: There were 21 observations read from the data set PG1.NP_SPECIES.
WHERE (Category='Mammal') and UPCASE(Common_Names) like '%FOX%';
NOTE: The data set WORK.FOX has 21 observations and 7 variables.
ok so then open up the dataset in the work library.
can't see your screen but generally if there is nothing in front of the dataset, then it is put into work library. if you want to see the dataset, then put it in a library that you do see in explorer. I've never heard of a missing work library and can't see your screen.
Hi:
The results from a DATA step program will NOT show in the Output window. You should have notes in the LOG, but unless you have a PROC PRINT after the DATA step, there is no output because the function of a DATA step is typically to create a data set. In class, we show you that you can browse to the data set and open it in the table viewer. For SAS Studio, we typically show just double clicking on the data set name in the WORK location; however, both Enterprise Guide and SAS on Windows should allow you to double click on the file to open in the default table viewer. You should be able to navigate to work in your SAS interface.
To answer your specific question, after I run the first query, I see rows where the "Fox Squirrel" is in the output data table, as shown below:
(this is looking at the table in the table viewer in SAS Studio but you should be able to open the table in SAS on Windows, SAS Enterprise Guide or SAS Studio)
So, now we need to eliminate the rows that have "Fox Squirrels" because we want only the foxes, not the squirrels with fox in the name. To eliminate the "squirrely" rows, now we need to change the WHERE:
So the PROC FREQ after that step shows just the count of the Mammals that are true foxes. If you do not get 21 on your first pass through the question and then 18 on your modified WHERE, I would suspect something is broken with the PG1.NP_SPECIES data file. You can always refresh the class data by re-running the data creation program.
Hope this helps,
Cynthia
she was using SAS studio. did you open the work library or could you post a screenshot of what you do see? you can see the dataset if you go to Explorer and click on Libraries and then 'Work'.
you might like using SAS studio more then since you don't have to go into an explorer window to see the dataset. the output window has the output from any procs you run. it sounds like Cynthia was talking about a proc freq that she ran.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.