DATA Step, Macro, Functions and more

import csv

Accepted Solution Solved
Reply
Contributor
Posts: 49
Accepted Solution

import csv

Hi,

I have a problem to import this file csv with these columnSmiley Sadin a I have the point, while in b I have the comma)

a          b                  

1          1,048

           356,8

3          6764

0.1       564

4          0,0019

1          0,0678

Obviously, I will have to do, some arithimetics operation between this coloumn and with other column from other table with COMMAX7.3 format.

have you any idea how to build the input statment in a data step?


Accepted Solutions
Solution
‎09-24-2014 03:14 PM
PROC Star
Posts: 7,468

Re: import csv

Can't u just use the commaxw informat?  e.g.:

data have;

  input a  b;

  informat b commax7.;

  format b best32.;

  cards;

1          1,048

           356,8

3          6764

0.1       564

4          0,0019

1          0,0678

;

View solution in original post


All Replies
Solution
‎09-24-2014 03:14 PM
PROC Star
Posts: 7,468

Re: import csv

Can't u just use the commaxw informat?  e.g.:

data have;

  input a  b;

  informat b commax7.;

  format b best32.;

  cards;

1          1,048

           356,8

3          6764

0.1       564

4          0,0019

1          0,0678

;

Contributor
Posts: 49

Re: import csv

Thanks!

PROC Star
Posts: 7,468

Re: import csv

Of course, if your csv is actually comma delimited as well, you'll have to account for the delimiter.  e.g., something like the following should work:

data have;

  infile cards dlm='~';

  input @;

  _infile_=substr(_infile_,1,find(_infile_,',')-1)||"~"||

   substr(_infile_,find(_infile_,',')+1);

  input a  b;

  informat b commax7.;

  format b best32.;

  cards;

1,1,048

,356,8

3,6764

0.1,564

4,0,0019

1,0,0678

;

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 202 views
  • 3 likes
  • 2 in conversation