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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi: I was looking at the table or data set in the table viewer inside SAS Studio. Basically, if you just double click on a data file, it will open in the table viewer. Enterprise Guide and SAS on Windows work the same way. If you find the file in your explorer list and double click, it should open in a table viewer.
What shows in the Results window or the Output window are the visible report results. For example, PROC SORT creates sorted data -- there's not any "report" other than log messages from PROC SORT -- so after you run PROC SORT, you only see log messages nothing in the Results window or the Output window. However, with procedures that produce output (PROC PRINT, PROC FREQ, PROC MEANS, PROC CONTENTS, to name a few) the formatted output will show in the Results window or the Output window. A DATA step program can produce an output report, but most often, a DATA step program only produces one or more data sets. So the only messages you see are LOG messages. If you get in the habit of always following your DATA step with a PROC PRINT then you'll always see something in the Results window. But what you're seeing is the output from PROC PRINT based on what the DATA step did. The DATA step messages will be in the SAS Log window.
Cynthia

View solution in original post

12 REPLIES 12
tarheel13
Rhodochrosite | Level 12

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. 

MartaZ
Fluorite | Level 6

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.

tarheel13
Rhodochrosite | Level 12

ok so then open up the dataset in the work library. 

MartaZ
Fluorite | Level 6
Hmmm. This is interesting, because I don't see the work library anywhere in my SAS folder/Explorer.
tarheel13
Rhodochrosite | Level 12

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. 

Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1650559296515.png

(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:

Cynthia_sas_1-1650559445105.png

  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

MartaZ
Fluorite | Level 6
Hi! When you say "this is looking at the table", where are you seeing the table? In the Results Viewer window, or the Output window, or somewhere else? I don't see a table at all in any of the windows.
Thanks!
tarheel13
Rhodochrosite | Level 12

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'.

MartaZ
Fluorite | Level 6
Thank you – I found the Work folder this morning. I was confused because I thought the table was supposed to show up in the Output window within SAS.
Which leads me to my next question: what is supposed to show up in the Output window in SAS?
tarheel13
Rhodochrosite | Level 12

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. 

Cynthia_sas
SAS Super FREQ
Hi: I was looking at the table or data set in the table viewer inside SAS Studio. Basically, if you just double click on a data file, it will open in the table viewer. Enterprise Guide and SAS on Windows work the same way. If you find the file in your explorer list and double click, it should open in a table viewer.
What shows in the Results window or the Output window are the visible report results. For example, PROC SORT creates sorted data -- there's not any "report" other than log messages from PROC SORT -- so after you run PROC SORT, you only see log messages nothing in the Results window or the Output window. However, with procedures that produce output (PROC PRINT, PROC FREQ, PROC MEANS, PROC CONTENTS, to name a few) the formatted output will show in the Results window or the Output window. A DATA step program can produce an output report, but most often, a DATA step program only produces one or more data sets. So the only messages you see are LOG messages. If you get in the habit of always following your DATA step with a PROC PRINT then you'll always see something in the Results window. But what you're seeing is the output from PROC PRINT based on what the DATA step did. The DATA step messages will be in the SAS Log window.
Cynthia

SAS Innovate 2025: Register Now

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 12 replies
  • 1701 views
  • 2 likes
  • 3 in conversation