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...

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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