BookmarkSubscribeRSS Feed
braam
Quartz | Level 8

Hi all, I would like to run a regression using proc surveyreg with a list of indicator variables (i.e., fixed effects). The procedure seems to treat the last group as the benchmark by default, but I would like to use another group as a benchmark. Is there any way to do so? For example, USA is the benchmark group when I run the following code, which I don't want.

 

proc surveyreg data= sashelp.cars ;
	class origin;
	model EngineSize= Horsepower MPG_City MPG_Highway Weight Wheelbase Length origin / solution; run;

 

I noticed that there is one way. It says that I need to get my variable formatted, which would take quite a lot of time: https://communities.sas.com/t5/SAS-Procedures/Changing-reference-level-for-categorical-variable-in-P...

I really hope that there is easier way to do so! Thanks!

7 REPLIES 7
Reeza
Super User
You can specify the level explicilty.

class origin (ref="LEVEL");
braam
Quartz | Level 8

Thanks, but it didn't work.

 

proc surveyreg data= sashelp.cars ;
	class origin (ref="LEVEL");
	model EngineSize= Horsepower MPG_City MPG_Highway Weight Wheelbase Length origin / solution; run;
Reeza
Super User

You need to replace LEVEL with the level you want, in this case USA

braam
Quartz | Level 8

Like this?

proc surveyreg data= sashelp.cars ;
	class origin (ref="Asia");
	model EngineSize= Horsepower MPG_City MPG_Highway Weight Wheelbase Length origin / solution; run;

As below, error is detected with "(".

4290  proc surveyreg data= sashelp.cars ;
4291      class origin (ref=Asia);
                       -
                       22
                       76
NOTE: The previous statement has been deleted.
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, :, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.
ERROR 76-322: Syntax error, statement will be ignored.
4292      model EngineSize= Horsepower MPG_City MPG_Highway Weight Wheelbase Length origin / solution;
4292!  run;
ERROR: Variable Origin should be either numeric or specified in the CLASS statement.
NOTE: The previous statement has been deleted.

ERROR: No MODEL statement.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SURVEYREG used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Still, doesn't work.... I saw a post saying that it may work for surveylogistic, but not for surveyreg. 

Reeza
Super User
What version of SAS/STAT do you have? It's listed as an option in SAS/STAT 15.1....otherwise, in that case you can only use FIRST/LAST which means you need to recode your variables so your reference category is either the first or last value, which kinda sucks to be honest. The good part is that they clearly know it's a desired feature 🙂
braam
Quartz | Level 8
Thanks. I use SAS 9.4. Could you please post your code (using sashelp.cars) if it worked for you?

By the way, my preferred benchmark is actually the FIRST one. Can I make my SAS use FIRST as a benchmark, instead of LAST? It would help.
Reeza
Super User


Thanks. I use SAS 9.4. Could you please post your code (using sashelp.cars) if it worked for you?



Your SAS version can have different SAS/STAT modules/versions installed. 

You can find your version by running the following and checking your log. 

 

proc product_status;
run;

 

 




By the way, my preferred benchmark is actually the FIRST one. Can I make my SAS use FIRST as a benchmark, instead of LAST? It would help.
class origin (ref = LAST);

If you want to use the last in the order as your reference, which implies last alphabetically by the way, not via data order.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 566 views
  • 0 likes
  • 2 in conversation