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
Super User

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
Super User

Great! So glad to help.

 

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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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