SAS suppress .lst files but keep ODS output - sas

I was doing a PCA analysis with SAS using the following code:
ods output Eigenvectors=PRINCEEV Eigenvalues=PRINCEEVAL;
proc princomp data=REPLACED PLOTS=SCORE(ELLIPSE NCOMP=5) NOPRINT;
id time;
run;
ods output close;
Because the lst files this analysis produces is too large, I used the NOPRINT option. However, it seems that the NOPRINT option also eliminates all of my ODS outputs. (Now PRINCEEV and PRINCEEVAL are all empty):
ERROR: File WORK.PRINCEEVAL.DATA does not exist.
ERROR: Export unsuccessful. See SAS Log for details.
259 putn
_______
1
259 ! ame=YES; run;
WARNING 1-322: Assuming the symbol PUTNAMES was misspelled as putname.
ERROR: File WORK.PRINCEEV.DATA does not exist.
ERROR: Export unsuccessful. See SAS Log for details.
ERROR: Errors printed on page 1.
Is there a way to suppress the generation of lst file, without affecting the ods output?
UPDATE:
It seems that according to the following sas blog, it is not possible to do that:
Can you combine NOPRINT and ODS OUTPUT?
SAS programmers crave efficiency. Upon reading that the NOPRINT option
can make a procedure run faster, the ambitious programmer might
attempt to run a procedure with the NOPRINT option but use the ODS
OUTPUT statement to capture the results of one table. Sorry, friend,
but you can't do that. The NOPRINT option means that no ODS tables are
created, so there is no way to select a table and save it to a data
set.
But the dilemma is, I have limited space on the cloud computing server. The lst files are doing nothing but wasting my spaces. Deleting the lst files when SAS programs are running with external processes will also produce an io error in SAS (I already tried that).
Is there anyway around?

I would suggest:
ods listing close ;
ods output Eigenvectors=PRINCEEV Eigenvalues=PRINCEEVAL;
proc princomp data=REPLACED PLOTS=SCORE(ELLIPSE NCOMP=5) NOPRINT;
id time;
run;
ods output close;
This will close the listing destination, so should work fine.
I noticed in a related blog post, Rick argued for:
ods exclude _all_ ;
http://blogs.sas.com/content/iml/2015/05/28/five-reasons-ods-exclude.html

Minor change to the previous answer: remove the NOPRINT option and after the ODS OUTPUT is created open up the ods listing if you have further code.
ods listing close ;
ods output Eigenvectors=PRINCEEV Eigenvalues=PRINCEEVAL;
proc princomp data=REPLACED PLOTS=SCORE(ELLIPSE NCOMP=5) /*NOPRINT*/;
id time;
run;
ods output close;
ODS LISTING;

If you execute your sas-script on your cloud computing server via bash, then you can send your .lst files to /dev/null:
sas -print /dev/null script.sas
The -print option only effects your .lst, but not any ODS related outputs.

Related

SAS ODS Query/Statement print along with it's output

SAS EG
Is there any way I can print the query/statement used to get the output, along with the output, using SAS ODS?
Suppose,
ods pdf file=pdfile;
proc sql;
select a.*
from tab1 a inner join tab2 b
on a.something=b.something
where <>
having <>;
quit;
ods _all_ close;
this would print the OUTPUT generated from the above query. But can I also get the query printed via the ods pdf along with the output?
There's no automatic way to redirect the log that I'm aware of.
There are a few ways to get what you want, however.
First off, if you are able to use Jupytr, SAS has plugins to enable that to work with SAS, and then you can simply write in the notebook and run the code, and the results appear with your code just as you want. See Chris Hemedinger's blog post on the subject for more details.
Second, SAS Studio will support a notebook-style interface probably with the next major revision (I believe version 5.0) which will release late next year. So similarly, you would put your code and get your output in the same windows.
Finally, the third option is to do as Reeza suggested - write to a log file, then print that to the output. It's messy but possible.
Here's an example of the latter. I don't make any effort to clean it up, note, you'd probably want to remove the logging related to PROC PRINTTO and the otehr notes (or turn on NONOTE).
ods pdf file="c:\temp\test.pdf";
filename logfile temp;
proc printto log=logfile;
run;
proc sql;
select * from sashelp.class;
quit;
proc printto;
run;
data _null_;
infile logfile;
input #1 #;
call execute(cats('ods text="',trim(_infile_),'";'));
run;
ods _all_ close;

SAS ODS output formatted weird

I'm trying to export a content to Excel. I use the below code but my output excel formatting is horrible.
ods excel file= "&cur_path/&project_name._Proc_Means.xlsx" style=printer ;
proc means data=&this_lib..&this_data;
run;
ods excel close;
The output looks like
The huge blank gap makes the file unreadable. I also find out that it puts all the outputs in the same row instead of many different rows.
Any suggestions on how to fix it?
Thanks in advance.
Assuming you have SAS 9.3+, which you must to use ODS EXCEL, you can add the stackodsoutput option to the PROC MEANS statement; that will give you a much more nicely formatted sheet.
ods excel file= "c:\temp\Proc_Means.xlsx" style=printer ;
proc means data=sashelp.cars stackodsoutput;
run;
ods excel close;
If you have prior to 9.3, you may want to use the OUT= option in PROC MEANS and then output the dataset yourself using PROC EXPORT or PROC PRINT. The default PROC MEANS ODS output is not very table-friendly.

2 proc print output in the same page (listing or rtf)

I am running two proc print and would like to compare them visually on the SAS listing output. Both proc print prints only 3 observations.
The issue is I can't have the 2 output in one and same page...I have to scroll down for one page to another page to look at the other output. I have tried option pagesize=MAX but it doesn't work (MIN neither)...Is there a way to achieve what I want ?
I was wondering if an ODS statement redirecting to RTF or (PDF) would do that ?
Thanks in advance
sas_kappel
Both ODS destinations can give you this, using the startpage=never option, which tells SAS not to start a new page when a new procedure is run.
These output to a results window, rather than the listing output.
option obs=3;
ods pdf startpage=never;
proc print data=sashelp.class;
run;
proc print data=sashelp.class;
run;
ods pdf close;
option obs=max;
For the listing destination, you can replace the pagebreak with another character (e.g. a space) by using the option: option formdlim=' ';.
Thanks Keith.
And would it be possible to have it directly in my output sas window ? I was thinking the ods statement ( as I only need the listing output) It doesn't seems to work:
option startpage=never obs=3;
proc print data=sashelp.class;
run;
proc print data=sashelp.class;
run;
option obs=max;
So I guess there is no other option to achieving this other than ODS statement ?

Clustermembers on SPDS 4.3

I am working with clustered datasets on SPDS 4.3.
I want to generate a list of the members for each cluster.
I found two possibilities to get the information I am looking for.
Either by using PROC CONTENTS and have a look on field "Cluster members are" or by using PROC SPDO like this:
PROC SPDO LIBRARY=P30C033;
CLUSTER LIST LD_LIQ_CLUS_Customer;
QUIT;
In both cases I get the information in form of a report.
But I would like to get the information in form of a dataset.
I already tried out= and out2= on PROC CONTENTS, but dont get the desired output.
I also searchd for options to PROC SPDO CLUSTER LIST, but with no result.
Thx in advance
MiKe
As a generic answer for any PROC, you can use ODS OUTPUT to get the dataset even if you can't use OUT= .
Add ODS TRACE ON; before the proc runs (and ODS TRACE OFF after it). It should give you some results in the log telling you what the output is named; you can then use ODS OUTPUT to get the results.
For example, with PROC CONTENTS, run:
ods trace on;
proc contents data=sashelp.class;
run;
ods trace off;
Mabe you see that the VARIABLES table looks interesting to you. So run:
ods output Variables=sasvars;
proc contents data=sashelp.class;
run;
ods output close;
ODS TRACE is not needed if you already know the name of the output portion, of course.
You can use ODS OUTPUT CLUSTERLIST= as shown in the below code example:
ods noresults;
ods output clusterlist=WORK.CLUSTER_MEMS;
proc spdo lib=SPDSLIB;
cluster list CLUSTER1;
cluster list CLUSTER2;
/* ... */
cluster list CLUSTERN;
quit;
ods output close;
ods results;
This allows you to capture one or multiple clusters' members into a single data set.
You can also capture cluster members to separate data sets using OUT= option:
proc spdo lib=SPDSLIB;
cluster list CLUSTER1 out=CLUSTER1_MEMBERS;
cluster list CLUSTER2 out=CLUSTER2_MEMBERS;
/* ... */
cluster list CLUSTERN out=CLUSTERN_MEMBERS;
quit;
For more on this topic see my recent blog post How to retrieve contents of a SASĀ® Scalable Performance Data Server library.

Determine ODS settings

I am working inside a SAS macro application, and get the following warning before running a proc compare:
WARNING: No output destinations active.
Using the noprint option of proc compare does not suppress the warning. Am pretty sure the only way to get rid of this warning is to open an ODS destination (eg ods listing;) before running the proc, however I do not want to disrupt existing settings as there may be different ODS states at run time.
Is there any way to determine the ODS state programmatically? eg:
%let state=%sysfunc(getODSSTATE(listing)); /* for example */
ods listing;
proc compare base=x compare=y noprint; run;
ods listing &state; /* either %str(CLOSE) or %str() */
I had thought ODS SHOW; would be a solution, but that tracks the select/exclude, not the open destination.
One solution might be to choose a destination that is unlikely to be open - an obscure tagset perhaps - and open that to a dummy file, then close it. ODS PREFERENCES;also seems like a good compromise; it will open up whatever your default destination is, at least.
Honestly though, if you're writing a macro application, I would just leave the ODS alone; it should be up to the programmer using your macro to properly set up ODS ahead of time.