Programming the statistical procedures from SAS

How to label the content of an output file from proc means ....

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

How to label the content of an output file from proc means ....

so that summaries from different files can be merged into one file. Procedures with a model statement have a labelling possibility, but what is the 9.4.-trick in proc means?

 

best

oyho


Accepted Solutions
Solution
‎02-28-2018 11:49 AM
Esteemed Advisor
Posts: 5,540

Re: How to label the content of an output file from proc means ....

How about using BY processing?

 

data all_panels;
set panel0_: indsname=_p;
panel = _p;
run;

proc means data=all_panels;
by panel notsorted;
var...;
output out=all_summary;
run;
PG

View solution in original post


All Replies
Super User
Posts: 6,785

Re: How to label the content of an output file from proc means ....

Have you examined the OUTPUT statement within PROC MEANS?

Occasional Contributor
Posts: 6

Re: How to label the content of an output file from proc means ....

Posted in reply to Astounding
Yes, I have.


It is said that label statements can be applied, period, but not how.


I tried:


output out = summary0_&d / label = 'panel&d' ; /* syntax error */


output out = summary0_&d label = 'panel&d'; /* syntax error */


output out = summary0_&d / autolabel ; /* no syntax error, but no label in the file either */


What works of course is the stupid solution: to add the labelling variable in a separate data step (see code below). My post is asking for a more elegant way --- which I presume exists.




%macro panel_stat;

%do d = 0 %to &n_panel;

proc means data = panel0_&d noprint;

var psqt psqt_aav psqt_aav2 aav aav2 t_panel yhat_sum yhat_midl1-yhat_midl&n_prod;

output out = summary0 ;

run;

data summary0_&d;

set summary0;

panel = &d;

run;

%end;


data summary0_&bas_aar;

merge summary0_0-summary0_&n_panel;

by panel;

run;


proc export data = summary0_&bas_aar

OUTFILE = "summary0_&bas_aar"

DBMS = xlsx

REPLACE;

run;


%mend;

%panel_stat;

Super User
Posts: 13,583

Re: How to label the content of an output file from proc means ....

if you are using a data set option to provide a label for a data set the syntax is

 

datasetname (label="quoted text")

dataset options have to appear within () and all of them within the same outer pair.

datasetname (keep= var1 var2 var3 rename=(var2=something) where=(var1 in (1 2 3)) label="quoted text" )

 

Occasional Contributor
Posts: 6

Re: How to label the content of an output file from proc means ....

Thanks for pointing to the appropriate syntax. Nevertheless, reading the documentation (http://support.sas.com/documentation/cdl/en/ledsoptsref/69751/PDF/default/ledsoptsref.pdf) it seems to me that this is a dead-end. I see no way to enter a 'label' variable into the data set using data set options. That is what I need, and what my stupid data step code provides. Please correct me if I am wrong.

 

Unless you can point to a better solution, I presume that my stupid code is the simplest alternative.

 

best

 

 

 

Solution
‎02-28-2018 11:49 AM
Esteemed Advisor
Posts: 5,540

Re: How to label the content of an output file from proc means ....

How about using BY processing?

 

data all_panels;
set panel0_: indsname=_p;
panel = _p;
run;

proc means data=all_panels;
by panel notsorted;
var...;
output out=all_summary;
run;
PG
Occasional Contributor
Posts: 6

Re: How to label the content of an output file from proc means ....

Thanks for constructive answer, which I mark as solved. Actually, my case is not solved by this because the panels are overlapping, but I didn't tell you.

oyho
Super User
Super User
Posts: 9,599

Re: How to label the content of an output file from proc means ....

The trick is to read the manual?  Come back with any specific questions, showing test data/required output, what code you have tried etc.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 181 views
  • 0 likes
  • 5 in conversation