DATA Step, Macro, Functions and more

Reading Negative Values with Parenthsis from Raw CSV

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

Reading Negative Values with Parenthsis from Raw CSV

Hi,

I'm trying to read a CSV with long records using "infile" statement. I can read the long record using "lrecl=" option. However, this file also has numeric values enclosed within parenthesis, which is giving me an error. I'm using the informat "comma". Can you please advise me how I can fix this? Thank you in advance!

Code:

data input_data;

    infile "&out_path./&fn." dlm="," dsd missover pad firstobs=2 obs=5 lrecl=5640;

    input

          CUSIP :$9.

          Yield_1 - Yield_912 :comma10.3

          dummy :$1;

     drop dummy;

run;

Observation value causing error:

0.670 , (5.095), 3.168

(Note, as the record is very long, I've only listed the values 323, 324 and 325. 323 and 325 are ready correctly)


Log:

NOTE: Invalid data for Yield_324 in line 5 1890-1897.


Accepted Solutions
Solution
‎07-02-2015 11:38 PM
Respected Advisor
Posts: 4,654

Re: Reading Negative Values with Parenthsis from Raw CSV

Try

(Yield_1 - Yield_912) (:comma10.)


instead. Without the parentheses, the comma. format applies only to the last variable in the list.


PG

PG

View solution in original post


All Replies
Solution
‎07-02-2015 11:38 PM
Respected Advisor
Posts: 4,654

Re: Reading Negative Values with Parenthsis from Raw CSV

Try

(Yield_1 - Yield_912) (:comma10.)


instead. Without the parentheses, the comma. format applies only to the last variable in the list.


PG

PG
Contributor
Posts: 30

Re: Reading Negative Values with Parenthsis from Raw CSV

PG,

Thank you for help! It worked. Smiley Happy

Asim

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 507 views
  • 1 like
  • 2 in conversation