BookmarkSubscribeRSS Feed
aarony
Obsidian | Level 7

I want to create three pfos for each year. my variable using to cut the observation is index1.

i want to use the mean and construct

pfo1: from the lowest number to mean - 1 std dev.

pfo 2: mean - 1 std dev to   mean - 1 std dev.

pfo 3: mean + 1 std dev to highest number

for each year.

i know how to obtain 1st and 99th percentile of the observations of each year

proc univariate data=pfo.merged_A1 noprint; var index1; by pfoyr;

output out=mean pctlpts=1 99 pctlpre=p; run;

i feel like i have to use something in that sort....

Many thx,

aaron

2 REPLIES 2
stat_sas
Ammonite | Level 13

If you are okay with proc sql then you can try something like

proc sql;

create table want as

select  pfoyr,min(index1) - std(index1) as profile1,

       avg(index1) - std(index1) as profile2,

       avg(index1) + std(index1) as profile3

from pfo.merged_A1

group by pfoyr;

quit;

Ksharp
Super User

If I understood what you mean.

data class;
 set sashelp.class;
run;
proc sort data=class;by sex;run;
proc summary data=class ;
by sex;
var weight;
output out=stat(drop=_:) mean=mean std=std;
run;
data want;
 merge class stat;
 by sex;
 select;
  when(weight(mean+std)) pfo=3;
  otherwise pfo=2;
end;
run;

Xia Keshan

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 930 views
  • 0 likes
  • 3 in conversation