BookmarkSubscribeRSS Feed
Pritish
Quartz | Level 8

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!!

4 REPLIES 4
ballardw
Super User

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?

Pritish
Quartz | Level 8

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

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

ballardw
Super User

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

Ksharp
Super User

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1021 views
  • 3 likes
  • 3 in conversation