/*Select Todays Date*/ %let tdy = %sysfunc(today()); %put tdy = &tdy.; /*Convert Into Month Portion Only*/ %let mnth = %sysfunc(month(&tdy.)); %put mnth = &mnth.; /*Convert To Year Portion Only*/ %let yr = %sysfunc(year(&tdy.)); %put yr = &yr.; /*Determine Last Month*/ %let l_mnth = %eval(&mnth. - 1); %put l_mnth = &l_mnth.; /*Convert To DateTime Value*/ %let dt_date = %sysfunc(mdy(&mnth.,1,&yr.),date9.):00:00:00; %put dt_date = &dt_date.; /*Select Month And Year (For Filename)*/ %let mon_yr_nm = %sysfunc(mdy(&mnth.,1,&yr.),monyy5.); %put mon_yr_nm = &mon_yr_nm.; /*Select Column For DDE Output Range*/ %let col = %eval((((&yr. - 2000) * 12) + &mnth.) - 70); %put col = &col.; /*Select Column Name For DDE Output Range*/ %let col_name = %sysfunc(mdy(&mnth.,1,&yr.),monname9.); %put col_name = &col_name.; /*Set Missing Values To Zero When Field Names Change Each Month*/ data one; input record_num 2. March_1 2. March_2 2. March_3 2. March_4 2.; cards; 1 1 2 3 4 2 1 2 . . 3 . . 3 4 4 1 . . 4 ; run; proc print data = one noobs; options nodate nonumber; title 'dataset one'; run; proc contents data = one noprint out = one_a (keep = name where = (name not in ('record_num'))); run; proc print data = one_a noobs; options nodate nonumber; title 'dataset one_a'; run; proc sql; create table one_b as select 'if '||trim(name)||' eq . then '||trim(name)||' = 0;' as sas_statments from one_a; quit; run; proc sql noprint; select sas_statments into: miss_2_zero separated by ' ' from one_b; quit; run; %put &miss_2_zero.; data two; set one; &miss_2_zero.; run; proc print data = two noobs; options nodate nonumber; title 'dataset two'; run;