PROC MEANS PROCEDURE

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

PROC MEANS PROCEDURE

Good morning, 

 

I have a problem with the PROC MEANS procedure. 

 

The problem is that I have a table with two variables

 -cod (is a code, numeric) 

 -cod2 (is another code, numeric) 

 

What I want to do is to make a PROC MEANS summarizing by cod and cod2. But PROC MEANS procedure gives me the variables _TYPE_ and _FREQ_ summarizing the variable cod and then the variable cod2 instead of doing together. 

 

My code is: 

proc means data=data.table1 noprint;
class cod cod2;
output out=data.table2;
run;

 


Accepted Solutions
Solution
‎06-11-2018 06:59 AM
New Contributor
Posts: 3

Re: PROC MEANS PROCEDURE

[ Edited ]
Posted in reply to CeliaAlonso

I get the solution it was doing this: 

proc summary data=data.table1 print; 
by cod cod2;
output out=data.table2; 
run;

 

Thanks for help anyways Smiley Very Happy

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: PROC MEANS PROCEDURE

Posted in reply to CeliaAlonso

Please provide test data in the form of a datastep (or use sashelp.xyz), as this helps us see what you have, and show what you want out.  You say you want to summarise cod and cod2, to which statistics?  _type_ and _freq_ are SAS derived variables, you can get stats out by (going to assume a few basic ones):

proc means data=data.table1 noprint; 
  var cod cod2;
  output out=data.table2 / n=n mean=mean median=median stddev=stddev min=min max=max; 
run;

This will give you a table (assumption as not seen data!) with cod and cod2 on two obs with the given stats as variables.  You can read in the manual further examples and full documentation.

http://documentation.sas.com/?docsetId=proc&docsetTarget=n1qnc9bddfvhzqn105kqitnf29cp.htm&docsetVers...

Solution
‎06-11-2018 06:59 AM
New Contributor
Posts: 3

Re: PROC MEANS PROCEDURE

[ Edited ]
Posted in reply to CeliaAlonso

I get the solution it was doing this: 

proc summary data=data.table1 print; 
by cod cod2;
output out=data.table2; 
run;

 

Thanks for help anyways Smiley Very Happy

Super User
Posts: 23,740

Re: PROC MEANS PROCEDURE

Posted in reply to CeliaAlonso

Several ways:

  • Use the NWAY option on the PROC MEANS statement so you only have the highest level.
  • Use the WAYS or TYPES statement to explicitly control the levels
  • Use a BY statement instead of CLASS
  • Use a PROC SQL instead if only doing a single statistics it's relatively easy.

 


@CeliaAlonso wrote:

Good morning, 

 

I have a problem with the PROC MEANS procedure. 

 

The problem is that I have a table with two variables

 -cod (is a code, numeric) 

 -cod2 (is another code, numeric) 

 

What I want to do is to make a PROC MEANS summarizing by cod and cod2. But PROC MEANS procedure gives me the variables _TYPE_ and _FREQ_ summarizing the variable cod and then the variable cod2 instead of doing together. 

 

My code is: 

proc means data=data.table1 noprint;
class cod cod2;
output out=data.table2;
run;

 


 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 135 views
  • 0 likes
  • 3 in conversation