x cd /pub/data/pl942000/Tools; %let pgm=genviews2; filename pgm "&pgm..sas"; *----Creates data views for ALL STATES IN US to specify geo levels and add esriid -----------------------------------; libname pl942000 '/pub/data/pl942000'; proc sql; *--create views of the commonly accessed geographic levels--; %macro cntyname; put(county,$county16.) as cntyname %mend cntyname; %macro doit(state,stab); %let esriid=%str( compress(geocode,'-.') as esriid ); /*<=========================Comment out===================================== %let moilks= %in(&state,(17 20 29)) ; %put state= &state moilks= &moilks; %if &moilks=0 %then %do; create view pl942000.&stab.stcnty(label="State and county summaries for &stab") as select &esriid, * from &stab.sums where sumlev in ('040','050'); %end; create view pl942000.&stab.places(label="Place data (155 & 160 sumlevs) for &stab") as select &esriid , %cntyname , * from &stab.sums where sumlev in ('155','160'); create view pl942000.&stab.tracts (label="Complete tracts (140 sumlev) for &stab") as select &esriid , %cntyname , * from &stab.sums where sumlev = '140'; create view pl942000.&stab.mcds(label="County subdivs (MCDs/Towns) for &stab") as select &esriid , %cntyname , * from &stab.sums where sumlev = '060'; create view pl942000.&stab.vtds (label="Voting Districts for &stab") as select &esriid , %cntyname , * from &stab.sums where sumlev = '700'; ===========================End commented out================================ */ %let esriid=%str(compress(county||tract||block,'.') as esriid ); ****This failed!!?? create view pl942000.&stab.blocks(label="Census blocks for &stab") as select &esriid , * from &stab.sums(drop=geocode areaname) where sumlev = '750'; create view pl942000.&stab.blocks(label="Block level subset of &stab.sums") as select * from &stab.geos(drop=geocode areaname where=(sumlev='750')) g , &stab.sumsng d where d.geo_id = g.geo_id; %mend doit; options nomprint nomlogic; *---invoke a macro for every state in U.S.---; %doit(01,al) ; %doit(02,ak) ; %doit(04,az) ; %doit(05,ar) ; %doit(06,ca) ; %doit(08,co) ; %doit(09,ct) ; %doit(10,de) ; %doit(11,dc) ; %doit(12,fl) ; %doit(13,ga) ; %doit(15,hi) ; %doit(16,id) ; %doit(17,il) ; %doit(18,in) ; %doit(19,ia) ; %doit(20,ks) ; %doit(21,ky) ; %doit(22,la) ; %doit(23,me) ; %doit(24,md) ; %doit(25,ma) ; %doit(26,mi) ; %doit(27,mn) ; %doit(28,ms) ; %doit(29,mo) ; %doit(30,mt) ; %doit(31,ne) ; %doit(32,nv) ; %doit(33,nh) ; %doit(34,nj) ; %doit(35,nm) ; %doit(36,ny) ; %doit(37,nc) ; %doit(38,nd) ; %doit(39,oh) ; %doit(40,ok) ; %doit(41,or) ; %doit(42,pa) ; %doit(44,ri) ; %doit(45,sc) ; %doit(46,sd) ; %doit(47,tn) ; %doit(48,tx) ; %doit(49,ut) ; %doit(50,vt) ; %doit(51,va) ; %doit(53,wa) ; %doit(54,wv) ; %doit(55,wi) ; %doit(56,wy) ; *dostates(n=51,msgs=1); quit;