options nocenter ; *by Jean Roth, jroth@nber.org, 2007-11-09 ; *NOTE: This program is distributed under the GNU GPL. See end of *this file and http://www.gnu.org/licenses/ for details. ; * The following line should contain the directory where the SAS file is to be stored ; libname library "~/bulk/hcris"; * The following line should contain the complete path and name of the raw data file. On a PC, use backslashes in paths as in C:\ ; %macro loop; %do year=1995 %to 2007; proc printto log ="./read_hosp_rpt_rollup&year..log"; proc printto print="./read_hosp_rpt_rollup&year..lst"; FILENAME datafile "/homes/data/hcris/fy/hosp_&year._ROLLUP.CSV"; * The following line should contain the name of the SAS dataset ; %let dataset=library.hosp_rollup&year.; data &dataset.; *hosp_dm.* files report lengths; *Using a length of 4 bytes retains 6 significant digits; *Largest integer represented exactly is 2,097,152; *Maximum values apply to 2002-09-30 data file; *max date is around 16000, do length of 4 should be fine for dates; LENGTH rpt_rec_num 5 label $30; * '2C' is hexadecimal for decimal 44 which represents ',' ; * '0D' is hexadecimal for decimal 13 which represents '\r', which is the carriage return character; infile datafile dsd delimiter='2C0D'x ; ** the ":" is a format modifier that reads data values that need additional instructions from an informat; INPUT rpt_rec_num label $ item ; LABEL rpt_rec_num="Report Record Number" ; proc sort data=&dataset.; by rpt_rec_num; proc transpose data=&dataset. out=&dataset. (drop=_NAME_ sortedby=rpt_rec_num); by rpt_rec_num; var item; id label; run; proc print DATA=&dataset. (obs=5); proc contents DATA=&dataset.; %end; %mend; %loop; /* Copyright 2007 shared by Jean Roth and the National Bureau of Economic Research National Bureau of Economic Research. 1050 Massachusetts Avenue Cambridge, MA 02138 jroth@nber.org This program and all programs referenced in it are free software. You can redistribute the program or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */