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.
Please paste usable code.
Copy the code back to SAS after pasting to ensure it can be run.
A simple Proc Reg call will give you both
ods select fitplot;
proc reg data = have;
model PERCENT = _yyyymm_;
run;quit;
"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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.