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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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