BookmarkSubscribeRSS Feed
sharmas
Calcite | Level 5


Hey all,

I ran into a problem and can't figure a way out. Your help is much appreciated.

Here is what I have,

Year             sex               Wage

2007              1                   14

2007              2                    12

2007             1                     12

2007              2                    13

I have data like that for many years(different files). My plan is to find the 10th, 50th, and 90th percentile of wages by sex for each of those year and finally combine them by year to plot a graph to see how things have changed in the last 10 years.

Here is the program I have, and I can find the percentile by sex using PROC Univariate. But I haven't been able to find a way to keep the Year in the output file so that I can combine it later.

proc

univariate data=hourly.out12hourly noprint

;

class

a_sex;

var log_hourly_annual;

output out=sex.percsex12 p10=p10str median=p50str p90

=p90str;

run

;

But I can't find a way to keep the year in the output file. All help is appreciated. Thanks.

3 REPLIES 3
Reeza
Super User

Can you add year into the class statement? I'm not sure it works with univariate, so if not try with proc means instead, the rest of the code stays the same, except univariate changes to means.

proc univariate data=hourly.out12hourly noprint;

class year a_sex;

types year*a_sex;

var log_hourly_annual;

output out=sex.percsex12 p10=p10str median=p50str p90=p90str;

run;

PGStats
Opal | Level 21

Why not do all years at once :

/* Merge the datasets */
data hourly;
set hourly.out10hourly hourly.out11hourly hourly.out12hourly;
run;

proc sort data=hourly; by sex year; run;

/* Get the percentiles */
proc univariate data=hourly;
by sex year;
var log_hourly_annual;
output out=perSexYear p10=p10str median=p50str p90=p90str;
run;

 

proc sgplot data=perSexYear;

series x=year y=p10str / group=sex;

series x=year y=p50str / group=sex;

series x=year y=p90str / group=sex;

run;

PG

PG
TomKari
Onyx | Level 15

Another option:

proc means data=out12hourly noprint nway nonobs;

var log_hourly_annual;

class year a_sex;

output out=medians p10()= median()= p90()=/autoname;

run;

Tom

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 801 views
  • 3 likes
  • 4 in conversation