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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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