DATA Step, Macro, Functions and more

Import question

Reply
Contributor
Posts: 65

Import question

Hi All,

I am trying to readin a pipe delimited file and have some issue with the readin program. Basically, the file has following layout:

Col_A| Col_B | Col_C

123|2013-05-22|99.12

45456|2013-05-27|1000

789|2013-05-28|56

101|2013-06-22|101.45

1233|2013-08-22|44.5643

I am using below code to readin above data:

data Want  ;

infile '../Text_file.txt' delimiter = '|' MISSOVER DSD lrecl=32767 firstobs=2 ;

                informat Col_A best32. ;

                informat Col_B yymmdd10. ;

                informat Col_C $10. ;

                format Col_A best32. ;

                format Col_B yymmdd10. ;

                format Col_C $10. ;

Input    

           Col_A

           COl_B

           Col_C $

;

Col_C_number =  Col_C * 1;

run;

When I try to convert Col_C to numeric, SAS outputs missing values for all Col_C value. I have following Note in the log file:

NOTE: Invalid numeric data, Col_C='99.12.' , at line 32 column 15.

I am guessing since there is no delimiter after Col_C, there is "." appended after each Col_C value.Can you please guide me on how to fix this issue?

Thanks for your time!!

Super User
Posts: 11,343

Re: Import question

I've never had a period appended to the last value of a pipe delimited file. You may have some artifact from text encoding such UNICODE that leaves little hidden surprises.

If you copy complete lines of data from the file and paste into a straight text editor such as Notepad do you see the period?

Contributor
Posts: 65

Re: Import question

No I don't see period if I copy data into notepad.

Do you think, I need to use recfm / encoding option?

Super User
Posts: 11,343

Re: Import question

Might be worth a shot. Do have any info such as a layout document or datadictionary from the data source?

Super User
Posts: 10,023

Re: Import question

Check infile option    termstr=      .Maybe you are importing DOS file under UNIX environment.

Ask a Question
Discussion stats
  • 4 replies
  • 224 views
  • 3 likes
  • 3 in conversation