BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dsam
Fluorite | Level 6
Another question is , how do i mask 001 in 001/Placebo in the plot. basically want to plot it just this way but not show subjid but plot it with a variable that has subjid/trt just like how you have it, just hide subjid in the labels
Ksharp
Super User
What picture you want to see (post an example)? You want Placebo or Trt appear multiple times in Y axis ?

dsam
Fluorite | Level 6
I posted a pic in the beginning of the post so there is an attachment in my first comment of this thread
Ksharp
Super User
"how do i mask 001 in 001/Placebo in the plot. "
What do you mean by that ? remove 001 002 in Y axis ?
dsam
Fluorite | Level 6
So plot it by subjectId but only display the treatment variable they took on y axis
Ksharp
Super User

You want this ? 

I have to leave now.

 



%let path= c:\temp ;


data have;
input study $ group : $20. value1 value2 sub_group $;
group2=scan(group,-1,'/');
cards;
study1 001/placebo 119 1 Allerg1
study1 001/placebo 115  8 Allerg2
study1 002/trt 112 4 Allerg1
study1 003/trt 112 2 Allerg1
study1 003/trt 112 6 Allerg2
study1 003/trt 110 2 Allerg3
study2 001/placebo 1129 . Allerg1
study2 001/placebo 1125 . Allerg2
study2 002/trt 1122 . Allerg1
study2 003/trt 1122 . Allerg1
study2 003/trt 1122 . Allerg2
study2 003/trt 1120 . Allerg3
;


proc format;
picture fmt
low-high='00009mg';
run;
options nodate nonumber orientation=portrait;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics /width=3.5in height=6in reset=index noborder imagename='FAS' outputfmt=png ;
proc sgplot data=have(where=(study='study1')) noautolegend nocycleattrs pad=0px;
title "Study1";
format value1 value2 fmt.;
hbarparm category=group response=value1/group=sub_group fillpattern nofill groupdisplay=cluster datalabel=sub_group ;
hbarparm category=group response=value2/group=sub_group   groupdisplay=cluster ;
xaxis  display=(nolabel) values=(0 to 150 by 50) ;
yaxis display=(novalues nolabel) ;
yaxistable group2/location=outside position=left VALUEJUSTIFY=right valueattrs=(size=10) labelattrs=(color=white);
run;

ods graphics /width=3.5in height=6in reset=index noborder imagename='PPS' outputfmt=png;
proc sgplot data=have(where=(study='study2')) noautolegend nocycleattrs pad=0px;
title "Study2";
format value1 value2 fmt.;
hbarparm category=group response=value1/group=sub_group fillpattern nofill groupdisplay=cluster datalabel=sub_group ;
hbarparm category=group response=value2/group=sub_group   groupdisplay=cluster ;
xaxis  display=(nolabel )   values=(0 to 1200 by 300) ;
yaxis display=(novalues nolabel) ;
yaxistable group2/location=outside position=left VALUEJUSTIFY=right valueattrs=(size=10) labelattrs=(color=white);
run;


ods pdf file="&path.\want.pdf" style=minimal dpi=300 ;
data x;
x=' ';y=' ';output;
run;
title;
proc report data=x nowd noheader style={outputwidth=100% };
column x y;
define x/display style(column)={just=r};
define y/display style(column)={just=l};
compute y;
n+1;
if n=1 then do;
call define('x','style','style={ postimage="&path\FAS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\PPS1.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
endcomp;
run;
ods pdf close;

Ksharp_0-1692620786959.png

 

dsam
Fluorite | Level 6
Yes this is what I want for y axis to display exactly! Thank you! Now just want to display values all of the ones I listed on x axis as separate ticks
Ksharp
Super User
/*
You could try options:
fitpolicy= VALUESROTATE=
*/
data have;
input study $ group : $20. value1 value2 sub_group $;
group2=scan(group,-1,'/');
cards;
study1 001/placebo 119 1 Allerg1
study1 001/placebo 115  8 Allerg2
study1 002/trt 112 4 Allerg1
study1 003/trt 112 2 Allerg1
study1 003/trt 112 6 Allerg2
study1 003/trt 110 2 Allerg3
study2 001/placebo 1129 . Allerg1
study2 001/placebo 1125 . Allerg2
study2 002/trt 1122 . Allerg1
study2 003/trt 1122 . Allerg1
study2 003/trt 1122 . Allerg2
study2 003/trt 1120 . Allerg3
;

proc format;
picture fmt
low-high='00009mg';
run;
ods graphics/height=10in width=10in noscale;
proc sgpanel data=have noautolegend nocycleattrs pad=0px;
panelby study/layout=panel columns=2 onepanel novarname ;
hbarparm category=group response=value1/group=sub_group fillpattern nofill groupdisplay=cluster datalabel=sub_group;
hbarparm category=group response=value2/group=sub_group   groupdisplay=cluster;
colaxis display=(nolabel)  fitpolicy=ROTATEALWAYS VALUESROTATE=vertical values=(0 to 1200 by 50) valuesformat=fmt.;
rowaxis display=none colorbands=even;
rowaxistable group2/ position=left VALUEJUSTIFY=right labelattrs=(color=white size=0) valueattrs=(size=10);
run;

Ksharp_0-1692704351843.png

 

Ksharp
Super User
If you need more control, I think you need to create two picture separately and combine them together into one picutre, Check this :
https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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