BookmarkSubscribeRSS Feed
monica1230
Calcite | Level 5

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?

12 REPLIES 12
AncaTilea
Pyrite | Level 9

According to SAS support:

SAS/STAT(R) 9.22 User's Guide

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.

monica1230
Calcite | Level 5

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.  

AncaTilea
Pyrite | Level 9

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.

Smiley Happy

Anca.

monica1230
Calcite | Level 5

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

AncaTilea
Pyrite | Level 9

Try using

Proc surveyreg  data = yourdata plots =....

Maybe it needs you to specify the data...

monica1230
Calcite | Level 5

I specified the dataset name but it still gave me the same error. I am out of ideas

PGStats
Opal | Level 21

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

PG
monica1230
Calcite | Level 5

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

Reeza
Super User

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.

monica1230
Calcite | Level 5

Thank you Reeze. I do need to use surveyreg with strata, cluster, weight and domain statements for analyzing NHANES data.

AncaTilea
Pyrite | Level 9

As noted,the plots option goes with the lsmeans statement,as I initially posted.

Anca

monica1230
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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