Data visualization with SAS programming

Question with a PROC SGPLOT

Reply
New Contributor
Posts: 2

Question with a PROC SGPLOT

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;

SAS Super FREQ
Posts: 3,791

Re: Question with a PROC SGPLOT

Posted in reply to Juan_Jose

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.

Super User
Posts: 11,517

Re: Question with a PROC SGPLOT

Posted in reply to Juan_Jose

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)

Ask a Question
Discussion stats
  • 2 replies
  • 70 views
  • 0 likes
  • 3 in conversation