Has anyone used Proc Surveyreg with Plots options for graphs? I tried it with ODS graphics on but it didn't work. I also tried LSMEANS statement but SAS told me it is a wrong syntax.
I used SAS 9.3 version. Anyone can help?
According to SAS support:
You need to use the LSMEANS statement with the PLOT option,
like this:
data IceCreamDataDomain;
input Grade Spending Income Gender$ @@;
datalines;
7 7 39 M 7 7 38 F 8 12 47 F
9 10 47 M 7 1 34 M 7 10 43 M
7 3 44 M 8 20 60 F 8 19 57 M
7 2 35 M 7 2 36 F 9 15 51 F
8 16 53 F 7 6 37 F 7 6 41 M
7 6 39 M 9 15 50 M 8 17 57 F
8 14 46 M 9 8 41 M 9 8 41 F
9 7 47 F 7 3 39 F 7 12 50 M
7 4 43 M 9 14 46 F 8 18 58 M
9 9 44 F 7 2 37 F 7 1 37 M
7 4 44 M 7 11 42 M 9 8 41 M
8 10 42 M 8 13 46 F 7 2 40 F
9 6 45 F 9 11 45 M 7 2 36 F
7 9 46 F
;
data StudentTotals;
input Grade _TOTAL_;
datalines;
7 1824
8 1025
9 1151
;
data IceCreamDataDomain;
set IceCreamDataDomain;
if Grade=7 then Prob=20/1824;
if Grade=8 then Prob=9/1025;
if Grade=9 then Prob=11/1151;
Weight=1/Prob;
run;
title1 'Ice Cream Spending Analysis';
title2 'Compare Domain Statistics';
proc surveyreg data=IceCreamDataDomain total=StudentTotals;
strata Grade;
class Gender;
model Spending = Gender / vadjust=none;
lsmeans Gender / diff plots=(diff meanplot(cl));
weight Weight;
run;
I hope this helps;
Anca.
Thank you, Anca! This is exactly what I did based on the SAS User Guide. But it didn't work. SAS log indicated wrong syntax. This is frustrating but I will try to run it again.
It would help if you posted the LOG (or some part of it - mainly containing the error) so we can figure out what syntax I wrong.
Anca.
I tried to run proc surveyreg with plots option:
ods graphics on;
proc surveyreg plots=fit;
model height=weight;
run;
ods graphics off;
But I get error, the log indicates as follow:
3330 ods graphics on;
3331 proc surveyreg plots=fit;
-----
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ALPHA, DATA, METHOD, MISSING, N,
NOMCAR, ORDER, R, TRUNCATE, VARMETHOD.
ERROR 76-322: Syntax error, statement will be ignored.
3332 model height=weight;
Why is SAS didn't have option PLOTS for me? Again, I have SAS 9.3
Thank you
Try using
Proc surveyreg data = yourdata plots =....
Maybe it needs you to specify the data...
I specified the dataset name but it still gave me the same error. I am out of ideas
There is no plots= option in the proc surveyreg statement in version 9.3. A fitplot was introduced in version 13, and for models involving a single regressor only (such as yours).
As a workaround, look into the effectplot of proc plm.
PG
Thank you very much for solving the puzzle for me. I will find another way, may be sgplot to graph the fitplot. I am not familiar with proc plm but I will look into it.
YuehYing
If you're using proc surveyreg as noted in your example above I don't believe you need surveyreg, but proc reg will suffice.
If you have a strata, wieght, cluster, contrast or domain statement as well then you probably need surveyreg.
Thank you Reeze. I do need to use surveyreg with strata, cluster, weight and domain statements for analyzing NHANES data.
Anca, thank you for pointing that out. I did use lsmeans statement with plots option but it did not generate fitplot which what I need.
SAS should revise their 13.1 user guide because here, it says that PLOTS is one of the options available in the proc surveyreg statement.
support.sas.com/documentation/cdl/en/statug/66859/HTML/default/viewer.htm#statug_surveyreg_syntax01.htm
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.