x cd /pub/data/saipe/Tools; %let pgm=cnvt_sd_20xx; filename pgm "&pgm..sas"; *--see companion setup cnvt_stcnty_20xx where we process state and county level data---; *---Starting with 2010 conversion run (2008 data) we change things so that only the new year(s) data is read. Then we append the new data to recreate the 20xx dataset. This requires 2 manual (interactive from SAS DM) actions: 1. Prior to running this setup, rename the saipe.usschldst20xx dataset to usschldst20xxB (for backup). ======================================================================!!!!!!!!!!!!!!!!!!!!!! Then run this setup which will create a new dataset for just the current year or years. It will also append those datasets to the old one (stored in the B dataset) and write a new usschldst20xx set. 2. After all is verified to be OK the backup dataset should be deleted. ----; %let lastyear=2004; *<==========================running 12-26-2006=========; %let lastyear=2005; *<==========================running 01-14-2008=========; %let lastyear=2007; *<==========================running 12-15-2008=========; %let lastyear=2008; *<==============================running 04-01-2010 with new data for 2008 and revised logic =======; %let lastyear=2009; *<==============================running 12-11-2010 with new data for 2009 =======; %let lastyear=2010; *<==============================running 11-30-2011 with new data for 2010 =======; %let lastyear=2011; *<==============================running 12-24-2012 with new data for 2011 =======; %let lastyear=2012; *<==============================running 01-23-2014 with new data for 2012 =======; %let lastyear=2013; *<==============================running 12-18-2014 with new data for 2013 =======; %let lastyear=2014; *<==============================running 12-09-2015 with new data for 2014 =======; %let lastyear=2015; *<==============================running 12-15-2016 with new data for 2015 =======; %let lastyr=%substr(&lastyear,3,2); libname saipe '/pub/data/saipe'; filename sddata "/pub/data/saipe/USSD&lastyr..txt"; options mprint; title "SAIPE conversion run - &pgm for Post-2000 Poverty and Income Estimates for School Districts"; data saipe.usschldst&lastyear(label="SAIPE School District Income & Poverty Ests &lastyear" sortedby=state NCEScode); infile sddata stopover; length Year $4 SumLev $3 State $2 Stab $2 NCEScode $5 Geocode $8 Areaname $65; length DESEcode $6; label DESEcode='Mo Dept of Elem & Secondary Ed Code'; length TotPopEst UnivPoorRelChild5_17 PoorRelChild5_17 5 PctPoorRelChild5_17 4 ; %macro readrec; %if &lastyear le 2009 %then %do; input state $char2. +1 NCEScode $char5. AreaName $10-74 TotPopEst 76-83 UnivPoorRelChild5_17 85-92 PoorRelChild5_17 94-101 _Yr $107-108 Release_Date $114-122; %end; %else %do; input state $char2. +1 NCEScode $char5. AreaName $10-81 TotPopEst 83-90 UnivPoorRelChild5_17 92-99 PoorRelChild5_17 101-108 _Yr $114-115 Release_Date $121-129; %end; %mend readrec; %readrec ; if UnivPoorRelChild5_17 then pctPoorRelChild5_17=100*PoorRelChild5_17/UnivPoorRelChild5_17; if state='29' then DESEcode=put(ncescode,$schcnvt6.); format pct: 5.1; Stab=put(state,$fipstab2.); Year='20'||_yr; SumLev='sch'; Geocode=State||'-'||ncescode; label Year='Income Year' SumLev='Geog. Summary Level'; drop _: ; return; run; proc sql; create table saipe.moschldst&lastyear as select * from saipe.usschldst&lastyear where state='29'; quit; data saipe.usschldst20xx(label="SAIPE Inc and Poverty Ests for Schl Dists 2000-&lastyear" index=(year) sortedby=year state ncescode ); set saipe.usschldst20xxB saipe.usschldst&lastyear ; *---could use proc append here, I suppose---; run; proc sql; create view saipe.moschldst20xx as select * from usschldst20xx where state='29'; quit; proc datasets library=saipe nolist; modify usschldst20xx; index create state; index create yearst=(year state); quit; proc print data=saipe.moschldst20xx(where=(Areaname=:'A')); title2 'Sample Observations from Missouri Schools with Names Beginning with A'; by year release_date state; id geocode areaname; run;