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

Hi SAS community,

 

I am new here and struggling to produce the graph figure attached here with datalinepatterns. The goal is to produce a bivariate graph of Q2(Have a condition needing care right away coded as "yes" or "No") and Q71(Race/Ethnicity coded as "Other/Mixed", "Black", "White"). See attachment labeled "datalinepatterns_graph.doc".

Just a note: All my variables are categorical. 

 

Here's my code and the output from the code is attached as well. Please see graph output in attachments.

 

Proc sgplot data = WORK.SASA;

yaxis valueattrs=(size=12pt) label = "Ethnicity";

xaxis valueattrs=(size=12pt) label = "Percentage";

hbar Q71 / GROUP = Q2 stat=Percent barwidth=0.85 seglabel dataskin=pressed;

title 'Condition needing urgent care vs race/ethnicity';

ods graphics / attrpriority=none;

styleattrs datalinepatterns=(dash shortdash);

keylegend / location=outside position=bottom across=1;

Run;

 

For reference, I am using SAS 9.4. I'm unable to include the dataset on here. Thank you for your help!

1 ACCEPTED SOLUTION
3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS community 🙂

 

You do not have to use datalinepatterns. What you want to do is to create a fillpattern. You can use the Journal2 style like this to make a graph that looks almost as you want. I included a small example with the sashelp.cars data set.

 

ods html style=journal2;

data cars;
  set sashelp.cars (where=(type ne 'Hybrid' and origin ne 'Asia'));
run;

title 'Mileage by Type and Origin';
proc sgplot data=cars noborder;
  hbar type / response=mpg_city stat=percent group=origin groupdisplay=stack
              displaybaseline=auto clusterwidth=0.7;
  yaxis display=(noticks nolabel);
  xaxis display=(noticks nolabel);
run;
PeterClemmensen
Tourmaline | Level 20

Great! So glad to help.

 

please remember to mark the answer as a solution. This helps other users navigate the forum 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2045 views
  • 2 likes
  • 2 in conversation