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;
For reference, I am using SAS 9.4. I'm unable to include the dataset on here. Thank you for your help!
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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.