Error reading fixed-formats in SAS

73 views Asked by At

Here are a few lines of data.

q  2016 55 59  580067.12 89453.03 74579.31 63005.34 54211.66
q  2016 60 64  826983.94119020.88 99145.49 85347.23 75223.34
q  2016 65 69 1080400.00139847.91116260.10103226.14 93063.24 
q  2016 70 74 1086917.25120158.78100291.15 91782.05 85081.34

I saved that in a file called "junk.txt". The follow bits of SAS code behave differently on those lines.

filename junk "junk.txt";

data temp;
   infile junk ;
   input 
   @1 TYPE $ 2.  
   @4 year 4.
   @9 age1 2.
   @12 age2 2.
   @15 foo 10.2 
   @25 bar 9.2 
   @34 YSD1-YSD3 9.2;   
run;

proc print;

data temp;
   infile junk ;
   input 
   @1 TYPE $ 2.  
   @4 year 4.
   @9 age1 2.
   @12 age2 2.
   @15 foo 10.2 
   @25 bar 9.2 
   @34 YSD1 9.2
   @43 YSD2 9.2
   @52 YSD3 9.2;   
run;

proc print;

I get an erroneous read from the first input, and a correct read from the second input. Trying to figure out what is going on. I actually have a lot more variables than 3, so being able to use the shortcut syntax would be useful to me.

1

There are 1 answers

0
Baltimark On

A colleague of mine was familiar with syntax I was not familiar with. The behavior of the following is the same as the behavior of my second technique.

filename junk "junk.txt";

data temp;
   infile junk ;
   input 
   @1 TYPE $ 2.  
   @4 year 4.
   @9 age1 2.
   @12 age2 2.
   @15 foo 10.2 
   @25 bar 9.2 
   @34 (YSD1-YSD3) (9.2);   
run;

proc print;