BookmarkSubscribeRSS Feed
Juan_Jose
Calcite | Level 5

Hello,  I have a code that was handled to me and I'm reviewing, I did not wrote the code.  I encontared several error in the following code, I am new to this function and can't figure out what is the fix, I would very much appreciate your help 

 

 

proc sgplot data = seg_tmp.all_v2;
format MNTH_SMRY_START_DT dtmonyy.
styleattrs
datacolors=(VIGB VLIGB orange)
DATACONTRASTCOLORS = (orange blue black);
vline MNTH_SMRY_START_DT / response=tot_trans_am grouporder=data stat=mean lineattrs=(thickness=2 PATTERN =solid);
vline MNTH_SMRY_START_DT / response=tot_trans_am grouporder=data stat=median y2axis lineattrs=(thickness=2 PATTERN =solid);
label MNTH_SMRY_START_DT = 'Month';
y2axis label='Median Transaction Amount';
yaxis label = 'Mean Transaction Amount';
xaxis label = 'Month';
by seg;
run;

 

And the error are as follows:

 

proc sgplot data = seg_tmp.all_v2;
 format MNTH_SMRY_START_DT dtmonyy.
 styleattrs
 datacolors=(VIGB VLIGB orange)
                  -                                  -
                 22                               22
                200                             200

 DATACONTRASTCOLORS = (orange blue black);
                                                                                -
                                                                               22
                                                                              200
WARNING: Variable STYLEATTRS not found in data set SEG_TMP.ALL_V2.
WARNING: Variable DATACOLORS not found in data set SEG_TMP.ALL_V2.
WARNING: Variable VIGB not found in data set SEG_TMP.ALL_V2.
WARNING: Variable VLIGB not found in data set SEG_TMP.ALL_V2.
WARNING: Variable ORANGE not found in data set SEG_TMP.ALL_V2.
WARNING: Variable ORANGE not found in data set SEG_TMP.ALL_V2.
WARNING: Variable BLUE not found in data set SEG_TMP.ALL_V2.
WARNING: Variable BLACK not found in data set SEG_TMP.ALL_V2.
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name, ;, -, :, _ALL_, _CHARACTER_, _CHAR_,
_NUMERIC_.
ERROR 200-322: The symbol is not recognized and will be ignored.
 vline MNTH_SMRY_START_DT / response=tot_trans_am grouporder=data stat=mean lineattrs=(thickness=2 PATTERN
! =solid);
 vline MNTH_SMRY_START_DT / response=tot_trans_am grouporder=data stat=median y2axis lineattrs=(thickness=2
                                                                                                                                 ------
                                                                                                                                  22
                                                                                                                                  76
 ! PATTERN =solid);
ERROR 22-322: Syntax error, expecting one of the following: FREQ, MEAN, SUM.
ERROR 76-322: Syntax error, statement will be ignored.
 label MNTH_SMRY_START_DT = 'Month';
 y2axis label='Median Transaction Amount';
 yaxis label = 'Mean Transaction Amount';
 xaxis label = 'Month';
 by seg;
 run;

2 REPLIES 2
Rick_SAS
SAS Super FREQ

I believe the code was written with a recent version of SAS and you are running it on an older version. The error that says 

ERROR 22-322: Syntax error, expecting one of the following: FREQ, MEAN, SUM.

indicates that STAT=MEDIAN is not support on your version of SAS. 

 

I think the DATACOLORS= option was added in SAS 9.4M3.

The STAT=MEDIAN option is relatively new...maybe SAS 9.4M5.

ballardw
Super User

Also

proc sgplot data = seg_tmp.all_v2;
format MNTH_SMRY_START_DT dtmonyy.      <= no ;  for format statement so styleattrs is treated as the next variable to apply a format to 
styleattrs
datacolors=(VIGB VLIGB orange)

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