BookmarkSubscribeRSS Feed
david27
Quartz | Level 8

Hello,

 

I have this data:

data have;
infile datalines dlm='';
input bin_val $8. variable_name $6. _yyyymm_ yymmn6. PERCENT ;
format _yyyymm_ yymmn6.;
datalines;
6.0-7.0 alpha 201503 0.54
6.0-7.0 alpha 201506 0.48
6.0-7.0 alpha 201509 0.47
6.0-7.0 alpha 201512 0.85
6.0-7.0 alpha 201603 0.74
6.0-7.0 alpha 201606 0.9
6.0-7.0 alpha 201609 1.12
6.0-7.0 alpha 201612 1.01
6.0-7.0 alpha 201703 0.99
6.0-7.0 alpha 201706 0.43
6.0-7.0 alpha 201709 0.47
6.0-7.0 alpha 201712 .
6.0-7.0 alpha 201803 0.46
6.0-7.0 alpha 201806 0.37
6.0-7.0 alpha 201809 0.34
6.0-7.0 alpha 201812 0.38
6.0-7.0 alpha 201903 0.34
6.0-7.0 alpha 201906 0.32
6.0-7.0 alpha 201909 0.27
6.0-7.0 alpha 201912 0.26
6.0-7.0 alpha 202003 0.3
6.0-7.0 alpha 202006 0.25
6.0-7.0 alpha 202009 0.26
;run;

I want equation y=mx+b equation for percent on Y-axis and _YYYYMM_ on X-axis.

I was able to get below chart and equation in excel but not sure how to get this in SAS.

I want the equation more than the chart. 

Please advise.

david27_0-1606198192729.png

 

 

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Please paste usable code.

Copy the code back to SAS after pasting to ensure it can be run.

david27
Quartz | Level 8
Updated. Apologies!!!
PeterClemmensen
Tourmaline | Level 20

A simple Proc Reg call will give you both

 

ods select fitplot;
proc reg data = have;
   model PERCENT = _yyyymm_;
run;quit;
ballardw
Super User

"Dates" on month intervals are not evenly spaced and the regression is going to be just a bit suspect.

If you actually need to know the slope, m, per calendar month then you may be better off creating a sequence variable instead of using a date. Or use a proper timeseries procedure.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 462 views
  • 1 like
  • 4 in conversation