sample data and plot desired is in the pic attached. I need to plot it group by variable Chall from sample data. Also need to pass a referenceline horizontally after each category of group2. I need each bar with same color as per the grouping variable but different pattern within a bar for example, solid patternuntil the value is scrndosen, linepattern until hardosen, dottedpattern until encdosn. I also need to show reference line by 600mg. I need to show all the doses as diaplayed on x axis. I need to show * when encdosn is less than or equal to hardosn.
data have;
infile cards expandtabs truncover;
input Sor :$20. scrndosn hardosn encdosn (group2 chall label) (:$20.);
labelposition=max(scrndosn, hardosn ,encdosn);
cards;
101/HDM 30 100 300 HDM cake
102/LDM 3 300 10 LDM cupcake *
102/LDM 600 2000 2000 LDM cake *
102/LDM 1000 4000 1000 LDM soda *
103/PDM 600 2000 4000 PDM soda
103/PLM 100 100 100 PLM cake *
104/PDM 100 100 1000 PDM water *
;
proc format;
picture fmt
low-high='00009mg';
run;
ods graphics /width=10in height=6in;
proc sgpanel data=have nocycleattrs noautolegend ;
panelby group2/layout=rowlattice novarname onepanel proportional uniscale=column NOHEADERBORDER HEADERBACKCOLOR=white;
hbarparm category=Sor response=encdosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=l1) baseline=1 ;
hbarparm category=Sor response=hardosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=r1) baseline=1;
hbarparm category=Sor response=scrndosn/group=chall groupdisplay=cluster baseline=1;
text x=labelposition y=Sor text=label/group=chall groupdisplay=cluster strip contributeoffsets=none
position=right textattrs=(size=20 color=black);
rowaxis display=(nolabel) discreteorder=data;
colaxis display=(nolabel) type=log integer valuesformat=fmt. valueshint offsetmax=0.02
values=(1, 3, 10, 30, 100, 300, 600, 1000, 2000, 4000) ;
refline 600/axis=x ;
run;
Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.
And when the values are picture it is even more useless. I am not going to retype values.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.
Or copy the values from the spread sheet, then open a text box using the </> and paste the TEXT of the values.
data have;
infile cards expandtabs truncover;
input Sor :$20. scrndosn hardosn encdosn (group2 chall label) (:$20.);
labelposition=max(scrndosn, hardosn ,encdosn);
cards;
101/HDM 30 100 300 HDM cake
102/LDM 3 300 10 LDM cupcake *
102/LDM 600 2000 2000 LDM cake *
102/LDM 1000 4000 1000 LDM soda *
103/PDM 600 2000 4000 PDM soda
103/PLM 100 100 100 PLM cake *
104/PDM 100 100 1000 PDM water *
;
proc format;
picture fmt
low-high='00009mg';
run;
ods graphics /width=10in height=6in;
proc sgpanel data=have nocycleattrs noautolegend ;
panelby group2/layout=rowlattice novarname onepanel proportional uniscale=column NOHEADERBORDER HEADERBACKCOLOR=white;
hbarparm category=Sor response=encdosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=l1) baseline=1 ;
hbarparm category=Sor response=hardosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=r1) baseline=1;
hbarparm category=Sor response=scrndosn/group=chall groupdisplay=cluster baseline=1;
text x=labelposition y=Sor text=label/group=chall groupdisplay=cluster strip contributeoffsets=none
position=right textattrs=(size=20 color=black);
rowaxis display=(nolabel) discreteorder=data;
colaxis display=(nolabel) type=log integer valuesformat=fmt. valueshint offsetmax=0.02
values=(1, 3, 10, 30, 100, 300, 600, 1000, 2000, 4000) ;
refline 600/axis=x ;
run;
/*
"it is only printing 1mg. 10mg, 100mg, 1000mg. it doesnt print any other values.."
You can make graphic be wider by "width=" And also try to remove option "valueshint".
Or you could post your real data,so I can replicate your problem.
For your second question, check the following code:
Or draw your picture more clear,so I know what you need.
*/
data have;
infile cards expandtabs truncover;
input Sor :$20. scrndosn hardosn encdosn (group2 chall label) (:$20.);
cards;
101/HDM 30 100 300 HDM cake
102/LDM 3 300 10 LDM cupcake *
102/LDM 600 2000 2000 LDM cake *
102/LDM 1000 4000 1000 LDM soda *
103/PDM 600 2000 4000 PDM soda
103/PLM 100 100 100 PLM cake *
104/PDM 100 100 1000 PDM water *
;
proc format;
picture fmt
low-high='00009mg';
run;
ods graphics /width=10in height=6in;
proc sgpanel data=have nocycleattrs noautolegend ;
panelby group2/layout=rowlattice novarname onepanel proportional uniscale=column NOHEADERBORDER HEADERBACKCOLOR=white;
hbarparm category=Sor response=encdosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=l1) baseline=1
datalabel=label datalabelattrs=(size=20 color=black) ;
hbarparm category=Sor response=hardosn/group=chall fillpattern nofill groupdisplay=cluster fillpatternattrs=(pattern=r1) baseline=1
datalabel=label datalabelattrs=(size=20 color=black);
hbarparm category=Sor response=scrndosn/group=chall groupdisplay=cluster baseline=1 datalabel=label
datalabelattrs=(size=20 color=black);
rowaxis display=(nolabel) discreteorder=data;
colaxis display=(nolabel) type=log integer valuesformat=fmt. offsetmax=0.03
values=(1, 3, 10, 30, 100, 300, 600, 1000, 2000, 4000) ;
refline 600/axis=x ;
run;
please see how my * is placed randomly on top instead of at the end of the bar. my code is below
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.