BookmarkSubscribeRSS Feed
dsam
Fluorite | Level 6

my code is below: I have x axis values like in months such as  D1 D28 2 3 4 6 12 18 24 36 but for one subject it is plotting month 18 after month 48 even though data is sorted properly by numeric variable.

 

title 'Percent Predicted FEV1 for Individual Subjects in Four 4D-710 Dose Cohorts';
proc sgplot data= combo;
xaxis grid type= discrete discreteorder= data;
series x = month y= RESTRESN/ group=subjid;
scatter x=month y= RESTRESN/ group= subjid ;
xaxis label= 'Month';
yaxis label= 'ppFEV1 (%)';
by cohort;
run;

3 REPLIES 3
Tom
Super User Tom
Super User

Most likely because the value of 18 did not appear in the first BY group.

 

Try adding observations for every possible MONTH value that have a new COHORT value that will sort before the others.

PaigeMiller
Diamond | Level 26

@dsam wrote:

my code is below: I have x axis values like in months such as  D1 D28 2 3 4 6 12 18 24 36 but for one subject it is plotting month 18 after month 48 even though data is sorted properly by numeric variable.

 

title 'Percent Predicted FEV1 for Individual Subjects in Four 4D-710 Dose Cohorts';
proc sgplot data= combo;
xaxis grid type= discrete discreteorder= data;
series x = month y= RESTRESN/ group=subjid;
scatter x=month y= RESTRESN/ group= subjid ;
xaxis label= 'Month';
yaxis label= 'ppFEV1 (%)';
by cohort;
run;


When you have multiple XAXIS statements, the second one replaces whatever is specified in the first.

--
Paige Miller
MarciaS
SAS Employee

Combine your two XAXIS statements into one statement since it appears the DISCRETEORDER= option is not being maintained. 

 

title 'Percent Predicted FEV1 for Individual Subjects in Four 4D-710 Dose Cohorts';
proc sgplot data= combo;
xaxis grid type= discrete discreteorder= data label= 'Month';
series x = month y= RESTRESN/ group=subjid;
scatter x=month y= RESTRESN/ group= subjid ;
yaxis label= 'ppFEV1 (%)';
by cohort;
run;

Hope that helps. 

Marcia 

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

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