BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
1 REPLY 1
msg
Calcite | Level 5 msg
Calcite | Level 5
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...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 791 views
  • 0 likes
  • 2 in conversation