When I read a dataset, it displays the contents in the output window correctly:
libname abc "dataset path";
data xyz;
set abc.wf91;
run;
but then when I give this command, it just takes me to the log window and displays nothing. No errors though, what am I doing wrong?
proc print data=xyz(obs=5);
run;
Thank you for helping!
I am sorry, I do not follow? Running a datastep should not display the contents of that dataset in the output window? What software are you using, e.g. SAS 9.4, Enterprise Guide, Visual Analytics etc. and exactly what code are you running - show the exact code, use sashelp.class if possible so we can run it as well e.g:
data xyz; set sashelp.class; run;
proc print data=xyz(obs=5);
run;
This should give you some notes in the log that the datastep and print worked. And in the output should be the output of the pro print.
I'm using SAS EG, this is the exact code that I was running (can't display the path due to confidentiality purposes):
First I ran this:
libname abc "path of the dataset";
data xyz;
set abc.wf_bl91;
run;
which displayed the dataset in the o/p window. Then I ran this:
proc print data=xyz(obs=5);
run;
which only produces logs with no warnings or errors, but no output.
Lets start over. Start a new session. In your code window put the code:
ods listing;
data xyz; set sashelp.class; run;
proc print data=xyz(obs=5);
run;
Run this. In the log you should see the above code with some notes after each block indicating how many records read.
1322 data xyz; 1323 set sashelp.class; 1324 run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.XYZ has 19 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1325 proc print data=xyz(obs=5); 1326 run; NOTE: There were 5 observations read from the data set WORK.XYZ. NOTE: The PROCEDURE PRINT printed page 2. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Open the output window, you should see:
The SAS System 14:50 Monday, June 18, 2018 2
Obs Name Sex Age Height Weight
1 Alfred M 14 69.0 112.5
2 Alice F 13 56.5 84.0
3 Barbara F 13 65.3 98.0
4 Carol F 14 62.8 102.5
5 Henry M 14 63.5 102.5
Please post the log. This code
data xyz;
set sashelp.class;
run;
proc print data=xyz(obs=5);
run;
produces this result:
Obs Name Sex Age Height Weight 1 Alfred M 14 69.0 112.5 2 Alice F 13 56.5 84.0 3 Barbara F 13 65.3 98.0 4 Carol F 14 62.8 102.5 5 Henry M 14 63.5 102.5
just as expected.
I tried running your code, all at once and one after another ((first the data set and then the proc print), and it shows the same result.
But for my code, when I run it together only then it gives the result in the result window, when I run those separately then the first part produces the dataset in the output window and when I run the proc print, I just get the logs with no errors or warnings.
1) Run your code
2) Go to the log
3) COPY the code and any messages from the log
4) Paste into a code box opened using the forum {i} menu icon as @RW9 did.
That we can confirm 1) that the library was successfully created, 2) the actual code you submitted, 3) the number of records in the resulting work.xyz data set and 4) any messages from Proc Print.
Is it possible that somehow the ODS LISTING destination has been closed? In that case, nothing would be written to the OUTPUT window, but there could be a WARNING (not an ERROR) in the SASLOG. What happens if you include the command
ods listing;
at the top of your program, and then run it?
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!
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.