Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: "invalid name"


From   Michael Palmer <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: "invalid name"
Date   Thu, 2 Aug 2012 05:31:13 +0000

Hello Stata-list

When I run the below program I get the error message: "invalid name pscoresample0.01" which is the first saved name from "predict pscore`i'`1'". Even if I use the strtoname command then I run into trouble later for the "caliper(`1')" which requires a number (not string format). 

Any suggestions anyone?

Thank you! 

**************************************************************************************************************************

capture program drop match
program define match

foreach i of varlist sample formal retired martyr disability_high ethnic hh_poor school farmer self_employed {

set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

logit insured age age_2 age_3 sex married hhead smoked sick_yr sick_days disability_high ///
CHI_dep literacy school primary second_lower second_upper post_second technical ///
pcexp pcexp_2 pcexp_3 skilled retired work_farm work_self work_state work_nonstate ///
hh_poor martyr ethnic ethnic_region ethnic_region_dum hhsize registered house_size house_perm house_semi ///
prop_age10 prop_age60 prop_male prop_dis rural commune_poor commune_remote comvol_ratio region1 region2 ///
region3 region4 region5 region6 region7 region8 month if `i'==1 [pw=weight]

predict pscore`i'`1'  

egen blockid`i'`1'=cut(pscore`i'`1') if pscore`i'`1'>=0.6, group(20)
tab blockid`i'`1'
forval z=0/19{
sum pscore`i'`1' if insured==0 & blockid`i'`1'==`z'
scalar N1=`r(N)'
sum pscore`i'`1' if insured==1 & blockid`i'`1'==`z'
scalar N2=0.05*`r(N)'
gen todrop = (scalar(N1)<scalar(N2))
drop if todrop==1 & insured==1 & blockid`i'`1'==`z'

drop todrop
                }

set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 insured age age_2 age_3 sex married hhead smoked sick_yr sick_days disability_high ///
CHI_dep literacy school primary second_lower second_upper post_second technical ///
pcexp pcexp_2 pcexp_3 skilled retired work_farm work_self work_state work_nonstate ///
hh_poor martyr ethnic ethnic_region ethnic_region_dum hhsize registered house_size house_perm house_semi prop_age10 ///
prop_age60 prop_male prop_dis rural commune_poor commune_remote comvol_ratio region1 region2 region3 region4 region5 region6 region7 region8 month ///
if `i'==1, outcome(ip_dum inpat_vis inpat_days inpat_commune inpat_district inpat_province inpat_public inpat_exp_total inpat_exp_med inpat_exp_med_a ///
inpat_exp_tests inpat_exp_tips inpat_exp_travel inpat_exp_vis) radius caliper(`1') common quietly

pstest, both

}

end 

match 0.01
match 0.001
match 0.0001

**********************************************************************************************************************************

Michael Palmer 
Research Fellow
Nossal Institute for Global Health, The University of Melbourne
Level 4, Alan Gilbert Bldg, cnr Grattan and Barry Sts, 
Carlton, Victoria 3010, Australia
T: +61 3 9035 8596; F: +61 3 9347 6872 
[email protected]
www.ni.unimelb.edu.au



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index