BookmarkSubscribeRSS Feed
hengophone
Calcite | Level 5

Hi all,

 

My goal is to produce several parameter-by-age series for each ID and have several reference percentiles on the same plot. Reference percentiles' data are provided for the age range of 24-240:

Age (in months)3rd Percentile BMI Value5th Percentile BMI Value10th Percentile BMI Value25th Percentile BMI Value50th Percentile BMI Value75th Percentile BMI Value85th Percentile BMI Value90th Percentile BMI Value95th Percentile BMI Value97th Percentile BMI Value
2414.5209514.7373215.0903315.7416416.5750317.5571918.1621918.6094819.3380119.85986
24.514.5034814.7192915.0711715.7196316.5477717.5212918.1195518.5611119.278919.79194
25.514.4688214.6836115.0333615.6763416.4944317.4513518.03668

18.4673

19.1646619.66102
........................

...

  

The actual data is much narrower by the age and also very scarce in datapoints for each ID. They have to be on the same dataset, so both setting and merging them together were tested, but desired output can't be achieved either way using SGPLOT. What is the key to have these series be plotted correctly?

Current code:

PROC SGPLOT DATA = plotdata;  
styleattrs datacontrastcolors=('red' 'green' 'blue' 'black' 'maroon');

SCATTER Y=chaaval X=ageass / MARKERATTRS = (SYMBOL=circlefilled size=5px  color="GREEN") legendlabel='Group 1' name='cohorta' ;
SERIES  Y=chaaval X=ageass / group=USUBJID datalabel=subjnum LINEATTRS = (THICKNESS = 2.25 COLOR="GREEN" PATTERN = Solid) legendlabel='Group 1' name="linea";
SCATTER Y=chbaval X=ageass / MARKERATTRS = (SYMBOL=circlefilled size=5px  color="RED") legendlabel='Group 2' name='cohortb' ;
SERIES  Y=chbaval X=ageass / group=USUBJID datalabel=subjnum LINEATTRS = (THICKNESS = 2.25 COLOR="RED" PATTERN = Solid) legendlabel='Group 2' name="lineb";

SERIES Y = _3RD_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='3rd percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _5TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='5th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _10TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='10th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _25TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='25th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _50TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=orange PATTERN = Solid) curvelabel='50th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _75TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='75th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _90TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='90th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _95TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='95th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
SERIES Y = _97TH_PERCENTILE_VALUE X = agem_htab / LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) curvelabel='97th percentile' CURVELABELATTRS=(SIZE = 5 COLOR=gray weight=NORMAL) CURVELABELLOC=OUTSIDE;
REFLINE 15 20 25 30 35 49/LINEATTRS = (THICKNESS = 1 COLOR=gray PATTERN = Solid) transparency=.3;
XAXIS label="BMI at Visit (months)" values=(24 to 132 by 12);
YAXIS label= "BMI" values=(15 to 40 by 5);
KEYLEGEND 'cohorta' 'cohortb' /title="Group:" location=OUTSIDE position=bottom autoitemsize;
run;

Data example:

subjnumAGEASSchaavalchbavalAVALagem_htab
199.87679671517.6.17.699.5
268.7310061616.4.16.468.5
273.65913757716.9.16.973.5
387.260780287.19.319.386.5
391.86036961.191991.5
472.542094456.19.219.272.5
556.509240246.16.716.756.5

Expected kind of plot:

hengophone_0-1723807793223.png

 

2 REPLIES 2
ballardw
Super User

How do we know what "series plotted correctly" would look like?

I am afraid that without actual working data step example data including some for the variables you show no values for such as Chaaval Chbaval Ageass Agem_htab

 

If USUBJID is individual identifier how many values are there? That has the possibility of making any graph next to useless if the number is excessive. With the number of different "series" plots you have that number might be excessive at a pretty small number.

 

The example "data" percentiles looks a bit like standard growth charts, is it? You may want to investigate the stuff at https://www.cdc.gov/nccdphp/dnpao/growthcharts/resources/sas.htm for what I think comes close.

hengophone
Calcite | Level 5

Yes, that is a CDC growth chart. 

The number of IDs that is expected on the plot is not too big, so it is not too cluttered.

Edited the post to include data example.

upd.: another edit to include desired output.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 321 views
  • 0 likes
  • 2 in conversation