turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- gbarline with stacked bars and a percentage for th...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-21-2011 03:42 PM

I am trying to insert a calculation into the plot statement in gbarline. I have code that successfully produces my stacked bars, but I cannot get the line to be a percentage. The datafile contains one record per observation, which seems to be necessary for the bars to stack correctly. Is it possible for the line to be a calculation?

I've tried putting the calculation into the plot stmt: plot / type=percent (flupos/pcr_count)

I've also tried putting the necessary denominator in the where statement as below.

proc gbarline data=six;

bar graphcode/ sumvar= ili

subgroup = subtype

clipref

width=5

FRAME MIDPOINTS=6 TO 58 BY 1

type=sum

coutline=black

raxis=axis1

maxis=axis2

legend=legend1;

plot flupos / type=percent

axis=axis3

legend=legend2;

where ili=1 and pcr_count=1;

format subtype subtype. graphcode graphcode.;

run;quit;

I've tried putting the calculation into the plot stmt: plot / type=percent (flupos/pcr_count)

I've also tried putting the necessary denominator in the where statement as below.

proc gbarline data=six;

bar graphcode/ sumvar= ili

subgroup = subtype

clipref

width=5

FRAME MIDPOINTS=6 TO 58 BY 1

type=sum

coutline=black

raxis=axis1

maxis=axis2

legend=legend1;

plot flupos / type=percent

axis=axis3

legend=legend2;

where ili=1 and pcr_count=1;

format subtype subtype. graphcode graphcode.;

run;quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-24-2011 01:58 AM

Just to be sure.

1) FLUPOS is a 0/1 var?

2) since you are doing a WHERE on ILI you would like the percent to be number of flu cases out of count within GRAPHCODE (across the SUBTYPE)?

3) check the specification of the PLOT statement (what version of SAS are you using).

1) FLUPOS is a 0/1 var?

2) since you are doing a WHERE on ILI you would like the percent to be number of flu cases out of count within GRAPHCODE (across the SUBTYPE)?

3) check the specification of the PLOT statement (what version of SAS are you using).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-24-2011 10:03 AM

Hi!

FLUPOS is a 0/1 variable.

The "where ili=1 and pcr_count=1" statement should allow the denominator to be the number of records in the dataset. This would then plot the % flu positive, with stacked bars showing the tally of the flu positives by subgroup (the types of flu).

In the code below, my bar statement says "bar graphcode/sumvar=ili", which gives me a stack that inclues flu negatives as a part of the bar. However, I want the plot line to be limited only to the flu positives out of the # ili (oy, I hope that made sense).

I'm using SAS 9.2

FLUPOS is a 0/1 variable.

The "where ili=1 and pcr_count=1" statement should allow the denominator to be the number of records in the dataset. This would then plot the % flu positive, with stacked bars showing the tally of the flu positives by subgroup (the types of flu).

In the code below, my bar statement says "bar graphcode/sumvar=ili", which gives me a stack that inclues flu negatives as a part of the bar. However, I want the plot line to be limited only to the flu positives out of the # ili (oy, I hope that made sense).

I'm using SAS 9.2

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-24-2011 01:47 PM

If FLUPOS is coded as 0/1 then MEAN instead of PERCENT will give you a percent of 1 coded responses, use an appropriate format for display.