BookmarkSubscribeRSS Feed
SusanParker
Calcite | Level 5
Using 9.2 M3 on Windows XP.

Here's my data:

data mydataset;
length subjid $9.;
infile datalines delimiter=',';
input subjid $ armcd pchg count;
datalines;
001-105-3,1,5.3,1
029-101-4,1,74.1,2
029-107-7,1,65.5,3
029-205-1,2,63,1
029-207-2,2,-62.7,2
001-303-7,3,-10.3,1
025-307-2,3,9.8,2
029-304-0,3,8.9,3
001-401-3,4,57.1,1
001-404-9,4,22,2
001-406-0,4,11.1,3
001-509-3,5,-7.7,1
001-511-2,5,24.3,2
001-512-0,5,0,3
025-506-4,5,-76.6,4
025-507-3,5,23.1,5
025-508-6,5,-17.4,6
029-501-8,5,17.3,7
029-503-4,5,36.4,8
029-505-2,5,-42.2,9
029-513-7,5,31.2,10
001-602-9,6,-33.3,1
001-606-5,6,-18.8,2
025-603-8,6,-51.8,3
029-601-5,6,-67.8,4
029-604-4,6,30.9,5
001-705-7,7,-94.8,1
025-701-7,7,-53.4,2
025-711-1,7,-37.5,3
025-712-7,7,3.3,4
029-703-0,7,9.9,5
029-704-8,7,-0.2,6
029-708-2,7,-0.9,7
;

I can get sort of what I want with
proc sgplot data=mydataset;
by armcd;
vbar subjid / response = pchg stat=sum;
run;

This gives me only the subjects that are in each arm. That is the only part of this that is what I want. What would be better would be panels that contain only the subjects that are each arm.

I tried
proc sgpanel data=mydataset nocycleattrs;
panelby armcd/ columns=7 novarname;
vbar subjid / response = pchg stat=sum nostatlabel barwidth=1;
run;

Having subjid was a bad idea, it tried to cram all 33 values of subjid into each panel. So I added a count variable to the dataset that is just 1 to whatever of subjects in the cohort. That comes a little bit better (just substituting count for subjid in the above code).

I figured I'd attempt GTL to see if I could get more control over the x-axis, but it didn't really work any better.

proc template;
define statgraph bestresp;
begingraph/designwidth=9in designheight=5.5in ;
layout datalattice columnvar=armcd / headerlabeldisplay=value;
layout prototype /cycleattrs=false;
barchart x=count y=pchg/ stat=sum barwidth=0.2;
endlayout;
endlayout;
endgraph;
end;
run;

proc sgrender data=mydataset template=bestresp;
run;

If you take the output from this sgrender and chop out the values of count (or preferably subjid) that don't belong to that armcd value, that's what I'm looking for.

Suggestions?

Thanks! Sue
8 REPLIES 8
DanH_sas
SAS Super FREQ
I think the key option you need is the UNISCALE option on the PANELBY statement. Here is a horizontal and vertical version of your plot. Let me know if this is what you want.

Thanks!
Dan

[pre]
proc sgpanel data=mydataset nocycleattrs;
panelby armcd/ rows=7 novarname uniscale=column;
hbar subjid / response = pchg stat=sum nostatlabel barwidth=1;
run;

proc sgpanel data=mydataset nocycleattrs;
panelby armcd/ columns=7 novarname uniscale=row;
vbar subjid / response = pchg stat=sum nostatlabel barwidth=1;
run;
[/pre]
GraphGuy
Meteorite | Level 14
Or maybe something like this, with traditional GGHCART ...

data robsdata; set mydataset;
barid=trim(left(armcd))||': '||trim(left(subjid));
run;

axis1 label=none value=(angle=90);
axis2 label=none minor=none offset=(0,0);
legend1 shape=bar(.15in,.15in);

proc gchart data=robsdata;
vbar barid / type=sum sumvar=pchg subgroup=armcd
maxis=axis1 raxis=axis2 legend=legend1;
run; Message was edited by: Robert Allison @ SAS
SusanParker
Calcite | Level 5
Too bad I can't get a combo of the two. Equal spacing for each subjid over the entire axis (like the gchart) but paneling so that I don't need color or fill attributes to distinguish the cohorts (like the sgpanel). I can't do unequal-sized panels, can I?

Thanks very much! This gives me two workable solutions without resorting to Excel, which is how these were done previously.
Jay54
Meteorite | Level 14
While this information will not be of help to you at this time, we do have plans for an option that will create PROPORTIONAL cell sizing based on number of bars in a cell.
SusanParker
Calcite | Level 5
That will, indeed, be useful. Thanks!
SusanParker
Calcite | Level 5
Hi Robert!

Based on input from others, I'm basically using your code. I needed to sort the bars within values of armcd, so this is where I am right now.

axis2 label=none minor=none offset=(0,0) order=(-100 to 100 by 10);
axis3 label=none minor=none offset=(0,0);

proc gchart data=mydataset;
format armcd armfmt.;
vbar newid / type=sum sumvar=pchg group=armcd nozero subgroup=armcd
maxis=axis1 raxis=axis2 ascending nolegend gaxis=axis3 ;
note move=(6,6.5) "Subjects with a percent change of 0 have no bar.";
run;
quit;

I added the gaxis to get rid of the label on the group. I gave the one zero-valued pchg a value of 0.00001 so that it would appear in the chart. Newid is just the middle 3 digits of subjid (because that indicates the cohort).

The thing that would make this just right would be if I could embed a carriage return, line feed (simulate what a split character for a column header in proc report would do) into my formatted values of armcd, so it could say Cohort 1 and then on the next line, what the treatment group is, such as 200 mg. I tried putting in what I thought were the unicode values for CR+LF into one of the format values and didn't get anywhere. I'm pretty sure I don't get use unicode inside the graph elements. Any suggestions?

Here's my options and goptions.

options orientation=landscape;
goptions hsize=9in vsize=5.3in device=png;
ods rtf file='test2.rtf' nogtitle nogfootnote;

And I'm sending it out to rtf.
GraphGuy
Meteorite | Level 14
I don't think you can use the carriage-return character in this case.

But SAS/Graph gchart bar value do honor a 'split' character (specified in the axis statement). You can define a character as the 'split' character, and then put that character wherever you want in your text, so that it will split the text onto 2 lines accordingly.

Here is my slightly modified version of a Tech Support example:

http://robslink.com/SAS/democd45/gchsplit.htm
http://robslink.com/SAS/democd45/gchsplit_info.htm

In this particular example, the backslash was used as the split character:

axis1 split="\" label=none offset=(9,9);
SusanParker
Calcite | Level 5
Excellent! I didn't know you could do that on the axis. That will do the trick.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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