BookmarkSubscribeRSS Feed
eperry12
Calcite | Level 5
Hello,
I am working on running a ZIP model with complex survey data, and want to use a domain statement to get results for males and females. But, I keep getting errors when I run the %SurveyGenmod macro. This is my first time using a macro, so I'm likely missing something obvious. In the documentation, the authors list a standard macro code and then apply that code to different examples. However, the applied codes leave off some of the things that the base code had. I've tried the codes in different ways, using the ZIP code they shared and also using the base code they shared, and I keep getting the same errors/warnings. Does anyone have any suggestions for how I can troubleshoot this issue? I really appreciate the support!! 
 
Liz
 
 
Code:
%surveygenmod(data=lesotho.lesotho_master10162023, y=HIVrisksum123, x= SV18_r EV18_r PVTOT18_r Q55dichot Q51_01 Q2 orphan3 Q9a_r,
dist=zip, xzip= Q2 orphan3 Q9a_r sv18_r ev18_r pvtot18_r Q55dichot Q51_01,
link=log, weight = individual_weight1, strata=DISTRICT, cluster=PSU, domain=fem, scale=,
vadjust=n, alpha=0.05);
 
Error:
65   %surveygenmod(data=lesotho.lesotho_master10162023, y=HIVrisksum123, x= SV18_r EV18_r PVTOT18_r
     -
     180
65 !  Q55dichot Q51_01 Q2 orphan3 Q9a_r,
WARNING: Apparent invocation of macro SURVEYGENMOD not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.
66   dist=zip, xzip= Q2 orphan3 Q9a_r sv18_r ev18_r pvtot18_r Q55dichot Q51_01,
67   link=log, weight = individual_weight1, strata=DISTRICT, cluster=PSU, domain=fem, scale=,
68   vadjust=n, alpha=0.05)
4 REPLIES 4
Amir
PROC Star

Hi,

 

The message in the log you have shared:

 

WARNING: Apparent invocation of macro SURVEYGENMOD not resolved.

 

implies the macro has not been defined. Just to rule out the obvious, did you copy the definition of the macro from page 16 onwards in the link you shared, and submit that macro definition in SAS first, before trying to invoke it?

 

 

Thanks & kind regards,

Amir.

eperry12
Calcite | Level 5

Thanks so much for your help, Amir! 

 

I'm new to these, so I didn't know I had to do that. So I copied the code starting on page 16 through the end of the documentation and ran that. On page 16 it has the macro code for the model first, so I tried to run that at the top of the code and then I tried to run it at the bottom of the long code, and then I tried to run it as two separate codes, with the long code first and then the model code second. If I run the long code on its own I don't get any errors (just the values are blank). If I run the model code before and after the long code I get dozens of errors, many new errors are in the code with my model, and there are also errors throughout the long macro code from the documentation. 

 

I really appreciate your help!!! 

 

All my best,

Liz

Amir
PROC Star

Hi,

 

No problem, happy to help if I can, although I doubt I will be able to go through all of the PDF you shared.

 

Ideally it is most useful to have a sample of data (in the form of a data step) plus the code you are using, so that we can easily replicate and attempt to diagnose the issue. I had trouble following the details of everything you tried running, so as an attempt to help share what we cannot see, I would suggest the following:

 

1) Start a new SAS session.

 

2) Submit the macro definition of surveygenmod from page 16 onwards (including %mend on the last page) in the PDF you shared. This should just tell SAS what surveygenmod should do if it is invoked, it doesn't actually invoke it at this stage.

 

3) Check all of the log. If there are no warnings or error messages then continue to the next step, otherwise please share the warnings and error messages using the Insert Code icon "</>" when posting, and then see if anyone is able to assist.

 

4) If the log had no issues then submit the following for diagnostics for the upcoming step:

 

options mprint symbolgen mlogic;

 

5) If the log had no issues then attempt to invoke (submit) %surveygenmod with the values you wanted to use with it.

 

6) Check all of the log again. If there are no warnings or error messages then continue to the next step, otherwise please share the warnings and error messages using the Insert Code icon "</>" when posting, and then see if anyone is able to assist.

 

7) Check your results and advise accordingly. If they are not what you expect then I would expect we will require sample data in the form of a data step.

 

 

Thanks & kind regards,

Amir.

eperry12
Calcite | Level 5

Thanks so much for all of your help!!

 

I was able to get the macro to run (that was my issue not running the first part of the code on page 16). However, I got errors when I entered my own information into the macro code. I decided to go with a different approach instead of trying to use a zip model. Thanks again for your help!

Cheers,

Liz

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1142 views
  • 1 like
  • 2 in conversation