BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SachinRuk
Calcite | Level 5
Hi All,

In my data step my period variable is numeric in format yymmdd8. My question is I want to do a proc summary such that:

proc summary data=mydata nvar;
class period;
var _numeric_ (except for period);
output out=mysummary sum=;
run;

Any thoughts?

Thanks,
Sachin
1 ACCEPTED SOLUTION

Accepted Solutions
advoss
Quartz | Level 8

Actually, since you are using period as your class variable, PROC SUMMARY will essentially ignore "period" as one of the _numeric_ variables and will issue the following:

WARNING: Variable period already exists on file WORK.MYSUMMARY.

WARNING: The duplicate variables will not be included in the output data set of the output statement number 1.

View solution in original post

7 REPLIES 7
ArtC
Rhodochrosite | Level 12
This comes close, although analysis is done on the CLASS variable it is eliminated from the data set. There is no NVAR option (that I know of).
[pre]proc summary data=sashelp.class;* nvar;
class age;
var _numeric_;
output out=mysummary(drop=age_:)
sum=/autoname;
run;
proc print data=mysummary;
run;[/pre]
SachinRuk
Calcite | Level 5
Appreciate the response.

and sorry that was meant to be nway. What does sum=/autoname do?

Thanks,
Sachin
SachinRuk
Calcite | Level 5
and the drop=age_: while Im at it. Not sure what it does specifically.

Thanks again
ArtC
Rhodochrosite | Level 12
The autoname option allows MEANS/SUMMARY to name the output variables - very handy for an automated session. Without it you MUST name the new variables if there is more than one analysis variable. The resultant naming convention is always analysisvar_statistic (such as AGE_SUM). In our case we want to drop all statistics (in the example there is only SUM) that are associated with AGE. This list of variables can be abbreviated by specifying AGE_: (the colon essentially says all variables that start with AGE_).
Ksharp
Super User
Then chang to use proc means;
[pre]

proc format;
value fmt
low-100 = 'thin'
101 - high='fat'
;
run;
proc means data=sashelp.class nway noprint;
class weight;
output out=mysummary sum= /autoname;
format weight fmt.;
run;
[/pre]


Ksharp Message was edited by: Ksharp
ballardw
Super User

If your original is doing most of what you want all you actually want to do is ignore the variable then drop it from analysis:

proc summary data=mydata (drop=period) nvar;

advoss
Quartz | Level 8

Actually, since you are using period as your class variable, PROC SUMMARY will essentially ignore "period" as one of the _numeric_ variables and will issue the following:

WARNING: Variable period already exists on file WORK.MYSUMMARY.

WARNING: The duplicate variables will not be included in the output data set of the output statement number 1.

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 20435 views
  • 2 likes
  • 5 in conversation