BookmarkSubscribeRSS Feed
Cruise
Ammonite | Level 13

I'd like to modify "Current Cluttered One" shown in the image to a Desirable Layout on the left where lines are paired by extra grouping variable Yes vs No using dashed line and colors combined. Yes vs No grouping in my data is Standard 1 vs 2. Snapshot of my data structure is shown right below. Could you please help modify the code below for me? The code is not accounting for Standard grouping variable yet. Excel data attached, if time to look at it.

age race1 year rate_ow rate_ob rate_obex standard
1 1 2002 26.8 5.1 7.0 1
1 1 2003 28.1 5.8 7.0 1
1 1 2004 27.9 6.1 7.1 1

...

 

1 1 2002 13.7 9.9 3.6 2
1 1 2003 14.8 10.3 3.4 2
1 1 2004 14.5 10.5 3.5 2

 

ods graphics / height=700 width=800;
proc sgpanel data=plot(where=(race1 ne 99));
panelby race1/novarname onepanel LAYOUT=panel columns=1 ROWHEADERPOS=right COLHEADERPOS=both SKIPEMPTYCELLS;
series y=rate_ob x=year/ group=age_6mo lineattrs=(pattern=solid) lineattrs=(thickness=2);
keylegend/title="AGE" position=top;
format age age. race1 racerace.;
colaxis label='YEARS' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2016 by 1);
rowaxis label='Overweight RATE (%)' grid;
title "Trends in Overweight Prevalence, 2002-2016";
run;

 

OBESITY PLOTS.png

12 REPLIES 12
DanH_sas
SAS Super FREQ

On the SERIES plot, set GROUPLP=Standard, and see if you get what you want.

 

Hope this helps!

Dan

Cruise
Ammonite | Level 13
1322  ods graphics / height=700 width=800;
1323  proc sgpanel data=temp.aplot(where=(race1 ne 99));
1324  panelby age/novarname onepanel LAYOUT=panel columns=1 ROWHEADERPOS=right COLHEADERPOS=both
1324! SKIPEMPTYCELLS;
1325  series y=rate_ob x=year/
1326  group=race1 GROUPLP=Standard lineattrs=(pattern=solid) lineattrs=(thickness=2);
                  -------
                  1
WARNING 1-322: Assuming the symbol GROUP was misspelled as GROUPLP.
1327  keylegend/title="AGE" position=top;
1328  format age age. race1 racerace.;
1329  colaxis label='YEARS' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2016 by 1);
1330  rowaxis label='Overweight RATE (%)' grid;
1331  title "Trends in Overweight Prevalence, 2002-2016";
1332  run;

Thanks @DanH_sas, above is the error message I get.

 

DanH_sas
SAS Super FREQ

What version of SAS are you running?

Cruise
Ammonite | Level 13
9.4
DanH_sas
SAS Super FREQ

The secondary grouping options for SERIES plots was introduced in 9.4, maintenance 2. If you must have either 9.4 or 9,4m1.

Cruise
Ammonite | Level 13

@DanH_sas

Supposed to have that option with this version, huh?

sas version.png

DanH_sas
SAS Super FREQ

Yes, is that version where you see the error?

Cruise
Ammonite | Level 13

@DanH_sas, yes, the error was from this version

Cruise
Ammonite | Level 13

@DanH_sas, Do you mind to post your code just used with me without formats?

DanH_sas
SAS Super FREQ

Here you go:

 

ods graphics / height=700 width=800;
proc sgpanel data=plot(where=(race1 ne 99));
panelby race1/novarname onepanel LAYOUT=panel columns=1 ROWHEADERPOS=right COLHEADERPOS=both SKIPEMPTYCELLS;
series y=rate_ob x=year/ group=age_6mo  lineattrs=(thickness=2) 
                         GROUPLP=standard grouplc=age_6mo name="age";
keylegend "age" / type=linecolor title="AGE" position=top;
keylegend "age" / type=linepattern title="Standard" position=bottom;
colaxis label='YEARS' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2016 by 1);
rowaxis label='Overweight RATE (%)' grid;
title "Trends in Overweight Prevalence, 2002-2016";
run;
DanH_sas
SAS Super FREQ

I just took your code (minus the formats) and the data, and ran it using the GROUPLP option on a Windows machine using 9.4m3, and it worked for me. I'm not sure why you're getting the syntax error.

Cruise
Ammonite | Level 13

@DanH_sas

No success. It appears that my SAS version is not supportive of it. Maybe I should try excel which is lot harder for me.

Thanks anyway, Dan.

1388  ods graphics / height=700 width=800;
1389  proc sgpanel data=plot(where=(race1 ne 99));
1390  panelby race1/novarname onepanel LAYOUT=panel columns=1 ROWHEADERPOS=right COLHEADERPOS=both
1390!  SKIPEMPTYCELLS;
1391  series y=rate_ob x=year/ group=age  lineattrs=(thickness=2)
1392                           GROUPLP=standard grouplc=age="age";
                               -------                     -
                               1                           22
                                                           76
WARNING 1-322: Assuming the symbol GROUP was misspelled as GROUPLP.

ERROR 22-322: Syntax error, expecting one of the following: CURVELABEL, LEGENDLABEL, NAME,
              SPLITCHAR.

ERROR 76-322: Syntax error, statement will be ignored.

1392!                          GROUPLP=standard grouplc=age="age";
                                                -------
                                                1
1393  keylegend "age" / type=linecolor title="AGE" position=top;
                        ----
                        22
                        76
1394  keylegend "age" / type=linepattern title="Standard" position=bottom;
                        ----
                        22
                        76
WARNING 1-322: Assuming the symbol GROUP was misspelled as grouplc.
ERROR 22-322: Syntax error, expecting one of the following: ;, ACROSS, AUTOITEMSIZE, BORDER,
              DOWN, NOBORDER, POSITION, TITLE, TITLEATTRS, VALUEATTRS.
ERROR 76-322: Syntax error, statement will be ignored.
1395  colaxis label='YEARS' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2016 by 1);
1396  rowaxis label='Overweight RATE (%)' grid;
1397  title "Trends in Overweight Prevalence, 2002-2016";
1398  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SGPANEL used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds

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
  • 12 replies
  • 2335 views
  • 0 likes
  • 2 in conversation