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

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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;

Ksharp_0-1692790372676.png

 

View solution in original post

18 REPLIES 18
dsam
Fluorite | Level 6
I attached sample data. I am not able to attach a pic of the plot that i handdrawn
dsam
Fluorite | Level 6
Here is the pic of what I want to get as a plot
ballardw
Super User

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.

 

 

Ksharp
Super User
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;

Ksharp_0-1692790372676.png

 

dsam
Fluorite | Level 6
This is working, thank you so much. there is only one problem wheni plot with my data. Because I have so many lines to represent, it is only printing 1mg. 10mg, 100mg, 1000mg. it doesnt print any other values.. that we defined here. also, might be the reason * is placed randomly on the bar rather than at the end of the bar when annotating. how do i fix that problem?
Ksharp
Super User
/*
"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;

Ksharp_0-1692877345111.png

 

dsam
Fluorite | Level 6
i did use width =2000px and remove valueshint option but no change.
Ksharp
Super User
Post your real data,so I can replicate your problem.

And I have to leave now, if I have time ,I will test it .
dsam
Fluorite | Level 6
I don't know if i cant the real data since it is company's confidentiality.
dsam
Fluorite | Level 6

dsam_0-1692878384401.png

please see how my * is placed randomly on top instead of at the end of the bar. my code is below

 

dsam_1-1692878491536.png

 

Ksharp
Super User
"how my * is placed randomly on top instead of at the end of the bar. "
What do you mean ? I don't understand .

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 18 replies
  • 3153 views
  • 0 likes
  • 4 in conversation