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

I'm trying to plot an average transition/mean and SD chart with sgplot+limitstat.

Elapsed time for the x-axis, use the variable VISITN.
The visit numbers are 0 6 7. (Baseline, Week 6, Week 7)

The time intervals on the x-axis are evenly spaced.
It is as if you are displaying Baseline Week1 Week2.
What should I do to reflect the actual time as shown in the figure?
Please help me.

== What I try/search ==
We CAN NOT do this with limitstat?
There was a sample that went through 1 data step and used scatter, yerrorlower, yerrorupper instead of limitstat.

https://www.sas.com/content/dam/SAS/ja_jp/doc/event/sas-user-groups/usergroups11-b-19.pdf 

(About Sample program, I also Thank to this site.)

 

 

data TEST;
ID =1;TREAT ="Placebo";GENDER ="Male";CAT =3;Visit ="Baseline";Visitn =0;VAL =54.9;output;
ID =1;TREAT ="Placebo";GENDER ="Male";CAT =3;Visit ="Week 6";Visitn =6;VAL =52.4;output;
ID =1;TREAT ="Placebo";GENDER ="Male";CAT =3;Visit ="Week 7";Visitn =7;VAL =62.9;output;
ID =2;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =3;Visit ="Baseline";Visitn =0;VAL =56.9;output;
ID =2;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =3;Visit ="Week 6";Visitn =6;VAL =47.4;output;
ID =2;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =3;Visit ="Week 7";Visitn =7;VAL =69.9;output;
ID =3;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =1;Visit ="Baseline";Visitn =0;VAL =64.9;output;
ID =3;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =1;Visit ="Week 6";Visitn =6;VAL =55.8;output;
ID =3;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =1;Visit ="Week 7";Visitn =7;VAL =46.7;output;
ID =4;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =2;Visit ="Baseline";Visitn =0;VAL =54.5;output;
ID =4;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =2;Visit ="Week 6";Visitn =6;VAL =47.9;output;
ID =4;TREAT ="TAK-XXX XXmg";GENDER ="Male";CAT =2;Visit ="Week 7";Visitn =7;VAL =59.6;output;
ID =5;TREAT ="Placebo";GENDER ="Male";CAT =2;Visit ="Baseline";Visitn =0;VAL =39.6;output;
ID =5;TREAT ="Placebo";GENDER ="Male";CAT =2;Visit ="Week 6";Visitn =6;VAL =56.1;output;
ID =5;TREAT ="Placebo";GENDER ="Male";CAT =2;Visit ="Week 7";Visitn =7;VAL =42.1;output;
ID =6;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =1;Visit ="Baseline";Visitn =0;VAL =50.3;output;
ID =6;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =1;Visit ="Week 6";Visitn =6;VAL =52.3;output;
ID =6;TREAT ="TAK-XXX XXmg";GENDER ="Female";CAT =1;Visit ="Week 7";Visitn =7;VAL =63.5;output;
run;

proc sgplot data=TEST ;
 vline VISIT /
 response = VAL
 group = TREAT
 stat = mean
 limitstat = stddev
 numstd = 1
 markers
 markerattrs
 = (symbol=circlefilled) ;
run ;

Result

 

99-now_result.png

 

 

 

 

 

 

 

 

 

 

 

what I want

 

98-i-want.png

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
proc sgplot data=TEST ;
 vline VISITn /
 response = VAL
 group = TREAT
 stat = mean
 limitstat = stddev
 numstd = 1
 markers
 markerattrs
 = (symbol=circlefilled) ;
 xaxis offsetmin=0.1 offsetmax=0.1 values=(0 to 7 by 1)
 valuesdisplay=('Baseline' ' ' ' ' ' ' ' ' ' ' 'Week 6' 'Week 7');
run ;

Ksharp_0-1681733407799.png

 

View solution in original post

3 REPLIES 3
Ksharp
Super User
proc sgplot data=TEST ;
 vline VISITn /
 response = VAL
 group = TREAT
 stat = mean
 limitstat = stddev
 numstd = 1
 markers
 markerattrs
 = (symbol=circlefilled) ;
 xaxis offsetmin=0.1 offsetmax=0.1 values=(0 to 7 by 1)
 valuesdisplay=('Baseline' ' ' ' ' ' ' ' ' ' ' 'Week 6' 'Week 7');
run ;

Ksharp_0-1681733407799.png

 

t_ar_taat
Quartz | Level 8

thank you. Even if I change "visit" to "visitn", my code didn't work either.
Looking at your code, the most effect seems to be the description of the Xaxis statement, thanks.

DanH_sas
SAS Super FREQ

Setting the tick values explicitly does work, but I wanted to make everyone aware of another alternative that might be more flexible if your data changes from run-to-run. The XAXIS for your VLINE chart can be set to be LINEAR, which will cause the numbers to be plotted linearly along the axis, while the plot is calculated discretely. Then, you can just define a user-defined format to turn the numbers into the correct strings. Below is the modification to your code to demonstrate this approach.

proc format;
value timeline 
0 = "Baseline"
1 = "Week 1"
2 = "Week 2"
3 = "Week 3"
4 = "Week 4"
5 = "Week 5"
6 = "Week 6"
7 = "Week 7";
run;

proc sgplot data=TEST ;
 format visitn timeline.;
 xaxis type=linear;
 vline VISITn /
 response = VAL
 group = TREAT
 stat = mean
 limitstat = stddev
 numstd = 1
 markers
 markerattrs
 = (symbol=circlefilled) ;
run ;

Hope this helps!

Dan

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