Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS Oddities/Input issues

SAS Oddities

SAS Oddities/Input issues

by  mycotropic  Posted    (Edited  )
Thought I would share this little incredibly irritating tidbit;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data one;
infile in1 delimiter=',' truncover dsd lrecl=13;
input visitnumber $ flights blocks ;

label flights = 'Flights per day';
blocks = 'Blocks per day';
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ok - When you are reading in comma delimited text of varying width AND you are being efficient and including a label statement to help your users, (This is the irritating part) and when you accidentaly use that extra ';' after the first label statement - SAS reads in the comma delimited file just fine, it then hits the 'flights' label and creates the label - SAS then begins feeding you "invalid numeric data" for your 'blocks' variable. A subsequent Proc Print will show the first two variables as having values and the third variable with no values.

Believe me when I say that you and your cooworkers can stare at the code for quite some time without realizing what that inapropriate ';' is doing to your data.

The correct code is obviously;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data one;
infile in1 delimiter=',' truncover dsd lrecl=13;
input visitnumber $ flights blocks ;

label flights = 'Flights per day'
blocks = 'Blocks per day';
run;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sans the first ';' and all is well, three variables with two labels all with values, rather then three variables with values and one with no data.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top