Online File
Rick Aster: Professional SAS Programming Shortcuts: Contents
proc sort data=county nodupkey; by county; run; * Create control dataset for value informat $COUNTY *; data cntl1; length type $ 1 fmtname $ 8 start $ 10 label $ 8 hlo $ 4; retain type 'J' fmtname '$COUNTY' hlo 'UJ '; set county (keep=county rename=(county=start)) end=last; start = upcase(start); label = put(_n_, s370fpib1.); output; if last then do; * Missing value. ; start = ' '; label = '00'x; output; * Invalid value. ; start = ' '; label = 'ff'x; hlo = 'UJO '; output; end; run; * Create control dataset for value format $COUNTY *; data cntl2; length type $ 1 fmtname $ 8 start $ 1 label $ 10 hlo $ 1; retain type 'C' fmtname '$COUNTY'; set county (keep=county rename=(county=label)) end=last; start = put(_n_, s370fpib1.); output; if last then do; * Missing value. ; start = '00'x; label = ' '; output; * Invalid value. ; start = ' '; label = '[$HEX2.]'; hlo = 'o'; output; end; run; * Create value informat $COUNTY from control dataset *; proc format cntlin=cntl1 library=library; run; * Create value format $COUNTY from control dataset *; proc format cntlin=cntl2 library=library; run;
proc sort data=county nodupkey; by county; run; data countyplus; set county end=last; output; if last then do i = _n_ + 1 to 254; county = put(i, hex2.); output; end; run; * Create control dataset for value informat $COUNTY *; data cntl1; length type $ 1 fmtname $ 8 start $ 10 label $ 8 hlo $ 4; retain type 'J' fmtname '$COUNTY' hlo 'UJ '; set county (keep=county rename=(county=start)) end=last; start = upcase(start); label = put(_n_, s370fpib1.); output; if last then do; * Missing value. ; start = ' '; label = '00'x; output; * Invalid value. ; start = ' '; label = 'ff'x; hlo = 'UJO '; output; end; run; * Create control dataset for value format $COUNTY *; data cntl2; length type $ 1 fmtname $ 8 start $ 1 label $ 10 hlo $ 1; retain type 'C' fmtname '$COUNTY'; set countyplus (keep=county rename=(county=label)) end=last; start = put(_n_, s370fpib1.); output; if last then do; * Missing value. ; start = '00'x; label = ' '; output; * Invalid value. ; start = ' '; label = 'FF'; hlo = 'o'; output; end; run; * Create value informat $COUNTY from control dataset *; proc format cntlin=cntl1 library=library; run; * Create value format $COUNTY from control dataset *; proc format cntlin=cntl2 library=library; run;