BookmarkSubscribeRSS Feed
_maldini_
Barite | Level 11

I am trying to produce a dataset that contains 3 variables (Year, Age, Population (ie. tot_pop)), and includes ONLY the maximum value of tot_pop for each year and age category (Formatted). The syntax below is not producing the desired output (See attachment for actual output).

 

 

PROC MEANS DATA=want NOPRINT MAXDEC=0;
CLASS year age;
VAR tot_pop ;
OUTPUT OUT=want_2 (drop=_FREQ_ _TYPE_)
MAX=tot_pop;
RUN;

I want the final dataset to look like this:

 

Year      Age      Population

2000    0-10     1,000,000 (Max value for year and age category)
2000   11-15    1,200,000  (Max value for year and age category)
2000   16-18    1,300,000  (Max value for year and age category)
2001    0-10     1,150,000  (Max value for year and age category)
2001   11-15    1,250,000  (Max value for year and age category)
2001   16-18    1,450,000  (Max value for year and age category)
Etc.

 

 

Thanks for your help here!

2 REPLIES 2
Reeza
Super User

That seems strange. Don't drop the _type_ columns and rerun. Post your log and output. 

 

Do you have a format applied to your CLASS variables?

Ksharp
Super User
PROC MEANS DATA=want NOPRINT MAXDEC=0 NWAY ;
CLASS year age;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 946 views
  • 0 likes
  • 3 in conversation