Hello,
I am trying to do chi2 tests and store the chi2, p, and the frequencies with the following code in a loop. For some of the variables of the loop, there are no observations for one of the options of 'sample' variable. This is creating problem and the 503 conformability error occurs and the program stops. I want the loop to continue with the next variable even in this case. I tried the below code but it doesn't work. Can somebody help please
code:
use "sampling_data_Jan30.dta", clear
keep if STATE_NAME=="ANDHRA PRADESH"
foreach v of varlist $nominal {
ds `v'
di `"`: var label `v''"'
display "ANDHRA PRADESH"
capture noisily tab sample `v' if share_irrigated_area>10 & STATE_NAME=="ANDHRA PRADESH",chi2 row matcell(rowfr_AP)
if _rc==0 {
matrix AP_nominal_chi2= (r(chi2),r(p) )
matrix rownames AP_nominal_chi2= `v'
matrix colnames AP_nominal_chi2 = chisquare pvalue
mat2txt, matrix(AP_nominal_chi2) sav("AP_nominal_chi2.xlx") append
matrix rownames rowfr_AP= `v' sample/nonsample
matrix colnames rowfr_AP= freq1 freq2
by sample, sort : egen `v'_pc=mean(100*`v')
mat2txt, matrix(rowfr_AP) sav("AP_rowfr.xlx") append
}
else continue
}
Related Posts with conformability 503 error in tab command
xtabond2 command : Fix for the Arellano-Bond Test for Autocorrelation of order 1Is it really mandatory to reject the Null Hypothesis of the Arrelano-Bond AR(1)? If so, is there a …
npregress intro manual replicate figuresHi, I'm looking for the code behind the figures in npregress intro manual https://www.stata.com/manu…
Moving entire folders to different directoriesHello: I am trying to use the command -mvfiles- which seems to be a good way to move/copy files from…
Question on select data for a specific periodHi! I'm having trouble with data cleaning. My time_var data is in long format (eg. 31may2011) and af…
Combining codes of different do filesI am trying to run the codes of two separate do files, combining them into the same do files. Each d…
Subscribe to:
Post Comments (Atom)
0 Response to conformability 503 error in tab command
Post a Comment