BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

The following output was made in R. I was wondering if there was a way to make something similar in SAS.

mariko5797_0-1656103498923.png

data _test1;
 label ELISA = "ELISA Total IgG Level"
		StDy = "Study Day";
 input ELISA StDy @@;
 cards;
6.94 1 6.97 8 7.11 29 6.95 36 7.12 57 6.70 64 7.13 92 7.01 124
7.06 1 6.89 8 7.28 29 6.93 36 7.05 57 7.00 64 7.04 92 7.21 124
7.05 1 7.11 8 7.03 29 6.98 36 7.04 57 7.08 64 6.87 92 6.81 124
6.95 1 7.05 8 6.98 29 6.94 36 7.06 57 7.12 64 7.19 92 7.12 124
6.91 1 6.89 8 7.23 29 6.98 36 6.93 57 6.83 64 6.99 92 7.00 124
;

data test1;
 label USUBJID = "Subject ID" TrtA = "Treatment Group";
 set _test1; usubjid = 1; trta = 'A'; 							 output;
 set _test1; usubjid = 2; trta = 'A'; elisa = 0.9*elisa + 0.02;  output;
 set _test1; usubjid = 3; trta = 'B'; elisa = 0.8*elisa + 0.32;  output;
 set _test1; usubjid = 4; trta = 'C'; elisa = 1.1*elisa - 0.62;  output;
 set _test1; usubjid = 5; trta = 'C'; elisa = 1.01*elisa + 0.08; output;
 set _test1; usubjid = 6; trta = 'D'; elisa = 1.01*elisa - 0.16; output;
 set _test1; usubjid = 7; trta = 'E'; elisa = 0.93*elisa + 0.11; output;
 set _test1; usubjid = 8; trta = 'E'; elisa = 0.87*elisa + 0.51; output;

proc sort; by trta stdy usubjid;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

How to calculate these Proportion of Subject ?

 

data _test1;
 label ELISA = "ELISA Total IgG Level"
		StDy = "Study Day";
 input ELISA StDy @@;
 cards;
6.94 1 6.97 8 7.11 29 6.95 36 7.12 57 6.70 64 7.13 92 7.01 124
7.06 1 6.89 8 7.28 29 6.93 36 7.05 57 7.00 64 7.04 92 7.21 124
7.05 1 7.11 8 7.03 29 6.98 36 7.04 57 7.08 64 6.87 92 6.81 124
6.95 1 7.05 8 6.98 29 6.94 36 7.06 57 7.12 64 7.19 92 7.12 124
6.91 1 6.89 8 7.23 29 6.98 36 6.93 57 6.83 64 6.99 92 7.00 124
;

data test1;
 label USUBJID = "Subject ID" TrtA = "Treatment Group";
 set _test1; usubjid = 1; trta = 'A'; 							 output;
 set _test1; usubjid = 2; trta = 'A'; elisa = 0.9*elisa + 0.02;  output;
 set _test1; usubjid = 3; trta = 'B'; elisa = 0.8*elisa + 0.32;  output;
 set _test1; usubjid = 4; trta = 'C'; elisa = 1.1*elisa - 0.62;  output;
 set _test1; usubjid = 5; trta = 'C'; elisa = 1.01*elisa + 0.08; output;
 set _test1; usubjid = 6; trta = 'D'; elisa = 1.01*elisa - 0.16; output;
 set _test1; usubjid = 7; trta = 'E'; elisa = 0.93*elisa + 0.11; output;
 set _test1; usubjid = 8; trta = 'E'; elisa = 0.87*elisa + 0.51; output;

proc sort data=test1; by trta stdy usubjid ;
run;


ods select none;
ods output cdfplot=cdfplot;
proc univariate data=test1 ;
by trta stdy  ;
cdfplot ELISA;
run;
ods select all;

data cdfplot;
 set cdfplot;
 inv_ECDFY=1-ECDFY*0.01;
run;

title;
ods graphics/reset attrpriority=none;
proc sgpanel data=cdfplot;
panelby  stdy /layout=panel  rows=4;
step x=ECDFX y=inv_ECDFY/group=trta markers;
keylegend /position=right across=1;
run;

 

Ksharp_0-1656155150221.png

 

 

View solution in original post

4 REPLIES 4
ballardw
Super User

To do anything resembling series plots you need a continuous X variable and a (more or less) continuous y variable.

Your final data set appears to have a variable Stdy that would control which graph panel items go into, and the Elisa variable that appears to be an X axis variable. Neither TrtA or Usubjid appear to be usable for a Y axis. So what type of plot do you want? The data shown doesn't match with the plots shown in form.

 

Adding a random Y axis variable:

data test1;
 label USUBJID = "Subject ID" TrtA = "Treatment Group";
 set _test1; usubjid = 1; trta = 'A'; 							 output;
 set _test1; usubjid = 2; trta = 'A'; elisa = 0.9*elisa + 0.02;  y=25*rand('uniform'); output;
 set _test1; usubjid = 3; trta = 'B'; elisa = 0.8*elisa + 0.32;  y=26*rand('uniform'); output;
 set _test1; usubjid = 4; trta = 'C'; elisa = 1.1*elisa - 0.62;  y=27*rand('uniform'); output;
 set _test1; usubjid = 5; trta = 'C'; elisa = 1.01*elisa + 0.08; y=28*rand('uniform'); output;
 set _test1; usubjid = 6; trta = 'D'; elisa = 1.01*elisa - 0.16; y=29*rand('uniform'); output;
 set _test1; usubjid = 7; trta = 'E'; elisa = 0.93*elisa + 0.11; y=24*rand('uniform'); output;
 set _test1; usubjid = 8; trta = 'E'; elisa = 0.87*elisa + 0.51; y=23*rand('uniform'); output;

proc sort data=test1; 
  by stdy trta elisa;
run;


proc sgpanel data=test1;
   panelby stdy /columns=3;
   series x=elisa y=y/ group=trta;
run;
/* or maybe*/
proc sgpanel data=test1;
panelby stdy /columns=3;
scatter x=elisa y=usubjid/ group=trta;
run;
/* or */

proc sgpanel data=test1;
panelby stdy /columns=3;
vbox elisa /category=usubjid group=trta;
run;

SGpanel creates groups of similar graphs with each panel definition coming from the variable(s) on the Panelby statement. There are a fair number of layout elements for the panels in options after the / on the Panelby statement.

 

A categorical group variable is typical way to show different related values with the Group=option.

 

 

 

 

 

 

mariko5797
Pyrite | Level 9
Y = Proportion of Subjects (%)
X = ELISA Results (OD450)
Grouped by treatment group (TRTA)
Paneled by study day (STDY)

It was requested to be reverse cumulative distribution, but I only saw SAS
documentation on normal cumulative distribution plots.
ballardw
Super User

Any percentage requires a denominator to calculate and I am not sure exactly what proportion you mean in this case for any given point.

 

 

Ksharp
Super User

How to calculate these Proportion of Subject ?

 

data _test1;
 label ELISA = "ELISA Total IgG Level"
		StDy = "Study Day";
 input ELISA StDy @@;
 cards;
6.94 1 6.97 8 7.11 29 6.95 36 7.12 57 6.70 64 7.13 92 7.01 124
7.06 1 6.89 8 7.28 29 6.93 36 7.05 57 7.00 64 7.04 92 7.21 124
7.05 1 7.11 8 7.03 29 6.98 36 7.04 57 7.08 64 6.87 92 6.81 124
6.95 1 7.05 8 6.98 29 6.94 36 7.06 57 7.12 64 7.19 92 7.12 124
6.91 1 6.89 8 7.23 29 6.98 36 6.93 57 6.83 64 6.99 92 7.00 124
;

data test1;
 label USUBJID = "Subject ID" TrtA = "Treatment Group";
 set _test1; usubjid = 1; trta = 'A'; 							 output;
 set _test1; usubjid = 2; trta = 'A'; elisa = 0.9*elisa + 0.02;  output;
 set _test1; usubjid = 3; trta = 'B'; elisa = 0.8*elisa + 0.32;  output;
 set _test1; usubjid = 4; trta = 'C'; elisa = 1.1*elisa - 0.62;  output;
 set _test1; usubjid = 5; trta = 'C'; elisa = 1.01*elisa + 0.08; output;
 set _test1; usubjid = 6; trta = 'D'; elisa = 1.01*elisa - 0.16; output;
 set _test1; usubjid = 7; trta = 'E'; elisa = 0.93*elisa + 0.11; output;
 set _test1; usubjid = 8; trta = 'E'; elisa = 0.87*elisa + 0.51; output;

proc sort data=test1; by trta stdy usubjid ;
run;


ods select none;
ods output cdfplot=cdfplot;
proc univariate data=test1 ;
by trta stdy  ;
cdfplot ELISA;
run;
ods select all;

data cdfplot;
 set cdfplot;
 inv_ECDFY=1-ECDFY*0.01;
run;

title;
ods graphics/reset attrpriority=none;
proc sgpanel data=cdfplot;
panelby  stdy /layout=panel  rows=4;
step x=ECDFX y=inv_ECDFY/group=trta markers;
keylegend /position=right across=1;
run;

 

Ksharp_0-1656155150221.png

 

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 4 replies
  • 2757 views
  • 1 like
  • 3 in conversation