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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 561 views
  • 0 likes
  • 2 in conversation