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;
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;
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;
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.
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?
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;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: