BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
smunigal
Calcite | Level 5

Hi all,

I am trying to generate bar graphs with 95% CIs for a variable called GROUP. The ADJ_PANC is the estimate and ADJ_PANC_LOW and ADJ_PANC_HIGH are 95% CIs. I would like to get these bar graphs separated by a width for a variable called TYPE.


Similarly for the second bar graph, I need the graphs separated by a variable called TYPE. However for this, for x-axis I would like to have the group variable labeled in two lines as they are too long.

eg. for BENIGN TUMOR, I need

BENIGN

TUMOR

For MALIGNANT TUMOR, I need

MALIGNANT
TUMOR

Is there a way I can generate this?

I would really appreciate any help with my sas code.

I am attaching a scanned document for what I am looking for exactly. Also I am attaching my raw csv files and sas code, and the graphs which I got with the sas code.

Please do let me know if you have any questions.

Thank you for your time,

Satish


Fig 2a.jpegFig 2b.jpeg
1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

For #1, I assume you don't want the label at all, so you can turn it off on the COLAXIS statement:

COLAXIS display=(nolabel);

For #2, use the NOVARNAME option on the PANELBY statement.

For #3, you can control the axes using the ROWAXIS (y-axis) and the COLAXIS (x-axis) statements.

The code below is the same as before, with #1 and #2 added:

proc sgpanel data=YourDataSet;

panelby type / layout=columnlattice uniscale=row novarname; /* to keep the bars the same width, add the PROPORTION option */

colaxis display=(nolabel);

vbarparm category=group response=adj_panc / limitlower=adj_panc_low limitupper=adj_panc_high;

run;

View solution in original post

8 REPLIES 8
DanH_sas
SAS Super FREQ

Try this for your two chart and see if you like it:

proc sgpanel data=YourDataSet;

panelby type / layout=columnlattice uniscale=row; /* to keep the bars the same width, add the PROPORTION option */

vbarparm category=group response=adj_panc / limitlower=adj_panc_low limitupper=adj_panc_high;

run;

If you want to remove the line between the types, use the NOBORDER option on the PANELBY statement.

Hope this helps!

Dan

smunigal
Calcite | Level 5

Fig 2a1.jpeg

Hi Dan,

Your code was helpful. I just need couple of modifications. Would be able to help me with that? I am attaching the figure I got after I used your code.

1.  I do not want GROUP on x-axis. Can I remove GROUP from the graph?

2. I do not want Type=Age Group Type=Sex; I just Need Age Group  Sex. It would be great if I can get Age Group and Sex on X-axis in place of GROUP.

3. I can control X-axis on sgpanel?

Is there a way I can do that?

I would appreciate if you can help me with this.

Thank you,

Satish

smunigal
Calcite | Level 5

In my question no. 3. I meant Y-axis limit

DanH_sas
SAS Super FREQ

For #1, I assume you don't want the label at all, so you can turn it off on the COLAXIS statement:

COLAXIS display=(nolabel);

For #2, use the NOVARNAME option on the PANELBY statement.

For #3, you can control the axes using the ROWAXIS (y-axis) and the COLAXIS (x-axis) statements.

The code below is the same as before, with #1 and #2 added:

proc sgpanel data=YourDataSet;

panelby type / layout=columnlattice uniscale=row novarname; /* to keep the bars the same width, add the PROPORTION option */

colaxis display=(nolabel);

vbarparm category=group response=adj_panc / limitlower=adj_panc_low limitupper=adj_panc_high;

run;

smunigal
Calcite | Level 5


Hi Dan,

Thank you. I used the code and it gives me exactly what I am looking for. Can u guide me how/ where to use PROPORTION to give me bar width the same for all?

DanH_sas
SAS Super FREQ

I put it in the comment beside the PANELBY statement so you could add it if your version of SAS supports it. After you add it, your PANELBY statement will look like this:

panelby type / layout=columnlattice uniscale=row novarname proportion;

smunigal
Calcite | Level 5

I use SAS 9.3 and it does not support Proportion option in PANELBY. I am using other option barwidth under vbar options. It does not give me exact same width for all my bars but it is close to what I am looking for.

Satish

data_null__
Jade | Level 19

You can answer all your questions yourself by looking at the online documentation for SGPANEL.

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
  • 1744 views
  • 3 likes
  • 3 in conversation