Help using Base SAS procedures

Multilevel Regression and Poststratification

Reply
Frequent Learner
Posts: 1

Multilevel Regression and Poststratification

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!

Respected Advisor
Posts: 4,919

Re: Multilevel Regression and Poststratification

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
Ask a Question
Discussion stats
  • 1 reply
  • 237 views
  • 0 likes
  • 2 in conversation