BookmarkSubscribeRSS Feed
smunigala
Obsidian | Level 7

Hi all,

I am looking for help in creating graphs with two sets of labeling for X-axis. I am attaching my excel sheet, SAS code and the graphs I had generated. Basicially I want two X-axis labeling (Independent Studies and Studies) in the same graph. If you look at my SAS code, for two different graphs, X axis is Studies and Independent Studies. My data is the same and graphs generated are the same. However, I want tow X-axis labels in the same graph (Studies and Independent Studies).Fig 1.jpegFig 1_New.jpeg

 

Thanks for all the help,

Satish

ods listing close;
ods graphics / reset width=600px height=400px imagename='Fig 1' imagefmt=jpeg;
ods html file='Surg.html' path='E:\HRM\Revised\Revised18_New' style=journal; 

/*ods html file='ap.html' path='C:\' style=journal; */
 proc sgplot data=graphs;
 scatter X=Studies Y=MP /  markerattrs=(color=blue symbol=CircleFilled size=8) name="scat" legendlabel="Motor Pattern";
 series X=Studies Y=MP /  lineattrs=(color=blue pattern=1) ;
scatter X=Studies Y=BP /  markerattrs=(color=red symbol=SquareFilled size=8) name="scat1" legendlabel="Body Pattern";
 series X=Studies Y=BP /  lineattrs=(color=red pattern=1) ;
scatter X=Studies Y=OutOb /  markerattrs=(color=green symbol=TriangleFilled size=8) name="scat2" legendlabel="Achalasia/ Outflow obstruction";
 series X=Studies Y=OutOb /  lineattrs=(color=green pattern=1) ;

 XAXIS TYPE = DISCRETE ;
 YAXIS LABEL = '% Accuracy'    VALUES = (0 TO 100 BY 10);
keylegend "scat" "scat1" "scat2"  "scat4"  / position=bottomleft
across=1 location=inside ;
 run;
ods html close;
ods listing;


ods listing close;
ods graphics / reset width=600px height=400px imagename='Fig 1_New' imagefmt=jpeg;
ods html file='Surg.html' path='E:\HRM\Revised\Revised18_New' style=journal; 

/*ods html file='ap.html' path='C:\' style=journal; */
 proc sgplot data=graphs;
 scatter  X=Independent_Studies Y=MP /  markerattrs=(color=blue symbol=CircleFilled size=8) name="scat" legendlabel="Motor Pattern";
 series  X=Independent_Studies Y=MP /  lineattrs=(color=blue pattern=1) ;
scatter  X=Independent_Studies Y=BP /  markerattrs=(color=red symbol=SquareFilled size=8) name="scat1" legendlabel="Body Pattern";
 series  X=Independent_Studies Y=BP /  lineattrs=(color=red pattern=1) ;
scatter  X=Independent_Studies Y=OutOb /  markerattrs=(color=green symbol=TriangleFilled size=8) name="scat2" legendlabel="Achalasia/ Outflow obstruction";
 series X=Independent_Studies Y=OutOb /  lineattrs=(color=green pattern=1) ;

 XAXIS TYPE = DISCRETE ;
 YAXIS LABEL = '% Accuracy'    VALUES = (0 TO 100 BY 10);
keylegend "scat" "scat1" "scat2"  "scat4"  / position=bottomleft
across=1 location=inside ;
 run;
ods html close;
ods listing;
4 REPLIES 4
ballardw
Super User

I can't tell if you are asking for two different axis labels for one graph, in which case look at the X2AXIS statement or two similar graphs with different Xaxis labels, which might be SGPanel.

 

I don't normally open Excel files but there wasn't any graph in yours so it doesn't help to answer appearance questions.

smunigala
Obsidian | Level 7

Fig 1.jpegFig 1_New.jpegHi,

Thanks for the quick reply. Yes, I am looking for two different axis labels for one graph. I attached the graphs as image (it was attached to the body of the text). If u see in the Figure 1, I have X- axis as Studies. I also want Independent Studies (in excel sheet) as X-axis label. Can you please help me with the X2AXIS sas code?

 

Thanks,

Satish

smunigala
Obsidian | Level 7

Hope this PDF attachment helps in communicating what I am looking for (2 X-axis lables in one graph).

 

Thanks,

Satish

Ksharp
Super User
Can you post it at ODS Graphic forum, not this forum .
Try  using X2AXIS statement.



SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1483 views
  • 0 likes
  • 3 in conversation