BookmarkSubscribeRSS Feed
Lynnctc
Calcite | Level 5

I'm trying do multilevel regression and poststratification based on this paper: http://aje.oxfordjournals.org/content/179/8/1025.short

I stuck the model prediction step now. I found their lecture note online (online note: http://www.cste2.org/webinars/webinarpdfs/GeospatialDataMethods82313.pdf) and try to modify it because I focused on county-level not census track block. 

 

My codes as following:

proc GLIMMIX data=brfss.b12c_sr noclprint;
class FIPS_C state Ragegrp sex Rrace4
Rrurality2 ad_mean;
model MH (EVENT='1') =
Ragegrp
sex
Rrace4
Rrurality2 ad_mean
/dist=binary solution;
random state fips_c(state) / solution;
weight rw;
ods output
parameterEstimates=beta_fixed
SolutionR=beta_random;
run;

 

%MACRO SIMU(outcome=, year=);
%do i=1 %to 1000;
data temp1; set beta&year._&outcome;
xbeta=int+int_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+agegrp+age_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+sexgrp+sex_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+race4+race4_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+fips_c+fips_c_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+state+state_se*rannor(ABS(INT(RAND('UNIFORM')*100000)))
+ad_mean*(ad_mean+ad_mean_se*rannor(ABS(INT(RAND('UNIFORM')*100000))))
;
p=exp(xbeta)/(1+exp(xbeta));
keep fips_c pop p;
run;
*summarize obesity by block (or county, or congressional district);
proc sql;
create table temp2 as
select distinct fips_c, sum(pop) as pop, (sum(p*pop)/sum(pop))*100 as &outcome
from temp1
group by fips_C;
quit;
proc append base=temp3 data=temp2 force;run;
%MEND;

 

However, it shows error:

 

ERROR: There were 1 unclosed %DO statements. The macro SIMU will not be compiled.
ERROR: A dummy macro will be compiled.

 

Does anyone ever done it before or know how should I modify it? Thank you so much!

1 REPLY 1
PGStats
Opal | Level 21

The error message states that your DO block started with statement 

 

%do i=1 %to 1000;

 

is never terminated by a %end; statement. I guess it should be inserted just before %MEND;

 

PG

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!

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
  • 1 reply
  • 910 views
  • 0 likes
  • 2 in conversation