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

I try to add a vertical reference line to a time series plot to indicate the year where the forecast starts, but keep getting this error message in sas log. The variable AY has the datetime format Year4. The sas code works for the plot until I add the refline statement. Will appreciate any help with the refline statement! Thanks!

xliu1_0-1614375450471.png

 

PROC SGPLOT DATA=BACHDEG_Forecast;
BAND Upper=u95 Lower=l95 x=AY / Legendlabel="95% Confidence Limits";
scatter x=AY y=degrees_usf;
series x=AY y=forecast;
refline "AY=2022" / axis=x lineattrs=(thickness=1 color=BLUE pattern=dash);
RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@xliu1 wrote:

I try to add a vertical reference line to a time series plot to indicate the year where the forecast starts, but keep getting this error message in sas log. The variable AY has the datetime format Year4. The sas code works for the plot until I add the refline statement. Will appreciate any help with the refline statement! Thanks!

xliu1_0-1614375450471.png

 

PROC SGPLOT DATA=BACHDEG_Forecast;
BAND Upper=u95 Lower=l95 x=AY / Legendlabel="95% Confidence Limits";
scatter x=AY y=degrees_usf;
series x=AY y=forecast;
refline "AY=2022" / axis=x lineattrs=(thickness=1 color=BLUE pattern=dash);
RUN;

REFLINE wants either a VARIABLE or an explicit Value that is associated with the Axis.

So one of

 

refline AY / <options>;

or

refline 2022 /<options>;

 

"AY=2022" would only be valid if the value "AY=2022" appears on your x axis, meaning the axis would be character valued.

 

If the axis is a date value then you would use a date literal value like "01JAN2022"d to provide a date. If you haven't used date literals before they must be in the Date9 (better) or Date7 appearance, in quotes, with the d immediately following the value.

View solution in original post

3 REPLIES 3
ballardw
Super User

@xliu1 wrote:

I try to add a vertical reference line to a time series plot to indicate the year where the forecast starts, but keep getting this error message in sas log. The variable AY has the datetime format Year4. The sas code works for the plot until I add the refline statement. Will appreciate any help with the refline statement! Thanks!

xliu1_0-1614375450471.png

 

PROC SGPLOT DATA=BACHDEG_Forecast;
BAND Upper=u95 Lower=l95 x=AY / Legendlabel="95% Confidence Limits";
scatter x=AY y=degrees_usf;
series x=AY y=forecast;
refline "AY=2022" / axis=x lineattrs=(thickness=1 color=BLUE pattern=dash);
RUN;

REFLINE wants either a VARIABLE or an explicit Value that is associated with the Axis.

So one of

 

refline AY / <options>;

or

refline 2022 /<options>;

 

"AY=2022" would only be valid if the value "AY=2022" appears on your x axis, meaning the axis would be character valued.

 

If the axis is a date value then you would use a date literal value like "01JAN2022"d to provide a date. If you haven't used date literals before they must be in the Date9 (better) or Date7 appearance, in quotes, with the d immediately following the value.

xliu1
Quartz | Level 8

Thanks. It works out perfectly!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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