Hello
What is the way to prevent print ?
i tried ODS close but it didnt work
proc freq data=sashelp.cars nlevels;
ods exclude onewayfreqs;
ods output
nlevels= want
(keep = tablevar nlevels NNonMissLevels NMissLevels
rename = (tablevar=VAR_NAME nlevels=n_levels));
Run;
Prevent the printing of what exactly?
If you just want to prevent the frequencies from printing just use the normal PROC FREQ options for that, no need to delve into how ODS works.
tables _all_ / noprint;
If you want to exclude the ODS output NLEVELS then say so in the ODS EXCLUDE statement.
1 ods exclude nlevels ; 2 ods output nlevels= want 3 (keep= tablevar nlevels NNonMissLevels NMissLevels 4 rename=(tablevar=VAR_NAME nlevels=n_levels) 5 ) 6 ; 7 8 proc freq data=sashelp.class nlevels; 9 tables _all_ / noprint; 10 run; NOTE: The data set WORK.WANT has 5 observations and 4 variables. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE FREQ used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
If you want to exclude all output use the special ODS keyword ALL. But make sure to reverse it by adding ODS EXCLUDE NONE when finished with the block of code that needs everything excluded.
ods exclude all;
ods output nlevels= want
(keep= tablevar nlevels NNonMissLevels NMissLevels
rename=(tablevar=VAR_NAME nlevels=n_levels)
)
;
proc freq data=sashelp.cars nlevels;
run;
ods exclude none;
Log
1 ods exclude all; 2 ods output nlevels= want 3 (keep= tablevar nlevels NNonMissLevels NMissLevels 4 rename=(tablevar=VAR_NAME nlevels=n_levels) 5 ) 6 ; 7 8 proc freq data=sashelp.cars nlevels; 9 run; NOTE: The data set WORK.WANT has 15 observations and 4 variables. NOTE: There were 428 observations read from the data set SASHELP.CARS. NOTE: PROCEDURE FREQ used (Total process time): real time 0.01 seconds cpu time 0.00 seconds 10 11 ods exclude none; 12 13 proc print data=want; 14 run; NOTE: There were 15 observations read from the data set WORK.WANT. NOTE: PROCEDURE PRINT used (Total process time): real time 0.03 seconds cpu time 0.00 seconds
@Ronein wrote:
Hello
What is the way to prevent print ?
i tried ODS close but it didnt work
proc freq data=sashelp.cars nlevels; ods exclude onewayfreqs; ods output nlevels= want (keep = tablevar nlevels NNonMissLevels NMissLevels rename = (tablevar=VAR_NAME nlevels=n_levels)); Run;
If you close ALL the ODS destinations then the ODS OUTPUT is likely not going to do anything as the there is not going to be any ODS output generated. As I understand it the ODS OUTPUT captures what is sent to the ODS destination into data set(s).
If you don't want the Nlevels ODS output to appear in your default ODS destination you would have to close the ODS and then direct the output to a different ODS destination, such as a document you then ignore.
But it may help to describe more of what you are attempting to accomplish overall instead of just one bit.
@Ronein wrote:
I just want to use the output data set and I dont need the print on screen
Just repeating what @Tom already shared:
Prevent the printing of what exactly?
If you just want to prevent the frequencies from printing just use the normal PROC FREQ options for that, no need to delve into how ODS works.
tables _all_ / noprint;
@Ronein wrote:
I just want to use the output data set and I dont need the print on screen
Repeat:
If you don't want the PROC FREQ Nlevels ODS output to appear in your default ODS destination you would have to close the ODS and then direct the output to a different ODS destination, such as a document you then ignore. Then close that and restart another ODS destination for your "screen".
With Proc Document you could compile the "desired" screen output elements into another document if that is the objection to the "screen" appearance of the Nlevels output from Proc Freq.
There may be other ways to get what you want in the data set but I guarantee it will take a lot more programming.
@Kurt_Bremser wrote:
Issue the ODS _ALL_ CLOSE immediately before ODS OUTPUT.
No need to be that drastic. Closing all of the ods outputs can cause havoc with environments like SAS/Studio that like to try and control the SAS session.
Instead you can just EXCLUDE the outputs you don't want printed.
1 ods exclude nlevels; 2 ods output nlevels=want; 3 proc freq data=sashelp.class nlevels; 4 tables _all_ / noprint; 5 run; NOTE: The data set WORK.WANT has 5 observations and 4 variables. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: PROCEDURE FREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.