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

Attempting to create a figure using proc sgplot.  Using the GROUP option and want the lines of each group to be different.  This is why I specify lineattrs=(pattern=).  When I do this, all of the lines on the graph have the same pattern.  How do I get the lines to be different patterns?  I have four different groups.

 


proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
density SampleMean/type=normal group=N lineattrs=(pattern=3);
xaxis label="X";
label N="Sample Size";
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaulN
Obsidian | Level 7

You search SAS documentation long enough and try...try...try...and try again, and you can solve your own problems.  I got it!


ods graphics on/attrpriority=none;

 

proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
styleattrs datalinepatterns=(dot dash solid longdash);
density SampleMean/group=N type=normal;
xaxis label="X";

 

ods graphics off;


label N="Sample Size";
run;

View solution in original post

5 REPLIES 5
ballardw
Super User

How "different" do you mean? Your code, as you have discovered sets the pattern to number 3. Period.

Did you run the code without the lineattrs option and didn't like it?

You can use the STYLEATTRS statement with the DATALINEPATTERNS option to provide a list of patterns to override the default such as

proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
styleattrs  datalinepatterns=(3 dot solid longdash ) ; 
/* obviously I do not know which patterns you want*/
density SampleMean/type=normal group=N;
xaxis label="X";
label N="Sample Size";
run;

 

PaulN
Obsidian | Level 7

When I exclude LINEATTRS=(PATTERN=), SAS gives me lines with different colors.  I need to produce a document in black and white so the different colors don't help that much.  Attempting to get the lines to appear different in a black and white document.

PaulN
Obsidian | Level 7

I changed my code to:


proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
styleattrs datalinepatterns=(dot dash solid longdash);
density SampleMean/type=normal group=N;
xaxis label="X";
label N="Sample Size";
run;

 

When I run the code SAS is using the FIRST datalinepatterns for all four groups.  I can't get SAS to use different patterns for different GROUPs.  Any suggestions?

Reeza
Super User

What about using a style to control that instead, Journal is a good one for black and white.

 


ods html file='path to your html file' style=journal;

proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
density SampleMean/type=normal group=N;
xaxis label="X";
label N="Sample Size";
run;

ods html close;
PaulN
Obsidian | Level 7

You search SAS documentation long enough and try...try...try...and try again, and you can solve your own problems.  I got it!


ods graphics on/attrpriority=none;

 

proc sgplot data=OutStats_sort;
title"Sampling Distribution of Sample Mean";
styleattrs datalinepatterns=(dot dash solid longdash);
density SampleMean/group=N type=normal;
xaxis label="X";

 

ods graphics off;


label N="Sample Size";
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 547 views
  • 0 likes
  • 3 in conversation