{Application 'POPSTANLFSEDITS' logic file generated by CSPro}
PROC GLOBAL
numeric individuals5To29 = 0;

PROC POPSTANLFS_FF

PROC DEMEDC

if DEMAG1 in 5:29 then
	inc(individuals5To29);
	
	// Check for currently in school in DEMEDC but
	// never attended in DEMEDL
	if DEMEDL = 1 and DEMEDC = 1 then
		errmsg("DEMEDL = never attended and DEMEDC = currently attending") summary denom = individuals5To29;
		
		// Set DEMEDL to less than primary
		impute(DEMEDL, 2);
	endif;
endif;

if not DEMAG1 in 5:29 and DEMEDC <> notappl then
	errmsg("DEMEDC not blank for age outside 5 to 29");
endif;
PROC AGFCHK

// Recode to yes/no repeating variable
{
if pos("1", AGFCHK) > 0 then
	AGFCHK_YESNO(1) = 1;
else
	AGFCHK_YESNO(1) = 0;
endif;
if pos("2", AGFCHK) > 0 then
	AGFCHK_YESNO(2) = 1;
else
	AGFCHK_YESNO(2) = 0;
endif;
if pos("3", AGFCHK) > 0 then
	AGFCHK_YESNO(3) = 1;
else
	AGFCHK_YESNO(3) = 0;
endif;
}

do numeric i = 1 while i <= length(AGFCHK)
	if pos(edit("9", i), AGFCHK) > 0 then
		AGFCHK_YESNO(i) = 1;
	else
		AGFCHK_YESNO(i) = 0;
	endif;
enddo;
	
PROC EMPLOYED


if EMPPAY = 1 then
	impute(EMPLOYED, 1);
elseif pos(AGFCHK, "3") > 0 then
	impute(EMPLOYED, 1);
elseif AGFMKT=1 then
	impute(EMPLOYED, 1);
elseif AGFMAI=1 then
	impute(EMPLOYED, 1);
elseif AGFHIS=1 then
	impute(EMPLOYED, 1);
elseif AGFHIR=1 then
	impute(EMPLOYED, 1);
else
	impute(EMPLOYED, 0);
endif;

