DATA Step, Macro, Functions and more

how to read thidsdata

Reply
N/A
Posts: 0

how to read thidsdata

I have text data delimited by comma as below

240,W,Ginger,,120
240,W,Protea,,180
356,W,Heliconia,,60


DATA A;
INFILE "d:\sas_data\data\testfile.csv" dlm = ',' missover ;
INPUT VAR1 VAR2 $ VAR3 $ VAR4 VAR5;
RUN;

result
240 W Ginger 120 .
240 W Protea 180 .
356 W Heliconi 60 .

the problem is sas doesn't read the 4th field (,,) between Ginger and 120
if i want to sas read it (not skip) and sas doesnt go to the new line when it is end of each record (after 120 it shoud go to new line), how can i do ?
thank in advance
Contributor msg
Contributor
Posts: 21

Re: how to read thidsdata

Hi,

I assume that you want your program to read the 4th field.

Since your data has two delimiters side by side, you need to introduce sensitivity to the program.

Introducing "DSD" will read that "missing" field.

== Start of code==;
data one;
input num1 text1 $ text2 $ text3 $ num2;
infile cards dsd dlm=',';
cards;
240,W,Ginger,,120
240,W,Protea,,180
356,W,Heliconia,,60
;
run;

proc print;
run;
== End of code==;


Thanks...
Ask a Question
Discussion stats
  • 1 reply
  • 98 views
  • 0 likes
  • 2 in conversation