Reading in decimal values? Trailing zero problem?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Reading in decimal values? Trailing zero problem?

I am having some problems reading in data from a csv file.

The data I want to read looks like this:

PID_KEY,UPC,VOLUME

39116156930650,1111161011,24.000000

28116704822202,1111161011,48.000000

...

My current code looks like this:

data aa;

infile './REDUCED_CLUSTER_PURCHASING.csv'

dlm=','

dsd

missover

firstobs=2;

input PID_KEY

     UPC

     VOLUME;

run;

The data step reads PID_KEY and UPC just fine, but errors on VOLUME, so that a proc print looks like this:

  Obs       PID_KEY          UPC        VOLUME

    1    100002005305     1700002404       .
    2    100005005605     5100019573       .
    3    100009005605     3700023068       .

What am I doing wrong/how can I read in my VOLUME variable?

Thanks!


Accepted Solutions
Solution
‎07-22-2013 10:43 PM
Super User
Posts: 9,681

Re: Reading in decimal values? Trailing zero problem?

It looks like your eof character is different from your OS.

try

termstr=crlf

or

termstr=cr

View solution in original post


All Replies
Super Contributor
Posts: 297

Re: Reading in decimal values? Trailing zero problem?

You have only supplied a small sample, but the following should get you started.

DATA WORK.WANT;

    LENGTH

        PID_KEY            8

        UPC                8

        VOLUME             8 ;

    FORMAT

        PID_KEY          BEST14.

        UPC              BEST10.

        VOLUME           BEST9.2 ;

    INFORMAT

        PID_KEY          BEST14.

        UPC              BEST10.

        VOLUME           BEST9.2 ;

    INFILE "E:\NEW TEXT DOCUMENT.TXT"

        LRECL=35

        DLM=','

  FIRSTOBS=2

        MISSOVER

        DSD ;

    INPUT

        PID_KEY          : ?? BEST14.

        UPC              : ?? BEST10.

        VOLUME           : ?? COMMA9.2 ;

RUN;

Solution
‎07-22-2013 10:43 PM
Super User
Posts: 9,681

Re: Reading in decimal values? Trailing zero problem?

It looks like your eof character is different from your OS.

try

termstr=crlf

or

termstr=cr

Super Contributor
Posts: 297

Re: Reading in decimal values? Trailing zero problem?

KSharpis right.  I forgot to run your code to see if it worked on my system first.

New Contributor
Posts: 3

Re: Reading in decimal values? Trailing zero problem?

That worked perfectly.

Thank you so much, Ksharp.

For some reason I can't tag your response as a correct answer, but as soon as I can, I will.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 267 views
  • 1 like
  • 3 in conversation