#!/bin/csh
## by Jean Roth, jroth@nber.org , 2016-01-27

set dataDir = "/homes/data/cps-basic/thedataweb.rm.census.gov/pub/cps/basic/201501-/"
foreach year (17)
   `rm -f /home/data/morg/raw/morg$year`
   `touch /home/data/morg/raw/morg$year`
   foreach mon ( jan feb mar apr may )
      set suffix = "pub.dat.gz"
      set dataFile = "$dataDir$mon$year$suffix"
      `gunzip -dc $dataFile | awk 'substr($0,64,1) == 4 || substr($0,64,1) == 8' >>/home/data/morg/raw/morg$year `;

   end
end


set dataDir = "/homes/data/cps-basic/thedataweb.rm.census.gov/pub/cps/basic/201701-/"
foreach year (17)
   foreach mon ( jun jul aug sep oct nov dec )
      set suffix = "pub.dat.gz"
      set dataFile = "$dataDir$mon$year$suffix"
      `gunzip -dc $dataFile | awk 'substr($0,64,1) == 4 || substr($0,64,1) == 8' >>/home/data/morg/raw/morg$year `;

   end
end

`compress /home/data/morg/raw/morg$year`
