Hi Everyone,
I want to read a pipe-delimited file which consists of some values as dots.
Ex : Var1|Var2|Var3
a |b |c
d |. |e
. |f |g
I have written the following program
data dummy;
infile "path\file.csv" dsd dlm="|" truncover LRECL=32767;
input var1 $char10. var2 $char10. var3 $char10.;
if _n_ = 1 then delete;
run;
But it is not working as expected. Can anyone please help me out. $char is considering default delimter as space. Can't we provide our own delimter?
data dummy; infile cards dlm='|'; input var1 : $char10. var2 : $char10. var3 : $char10.; if _n_ = 1 then delete; cards; Var1|Var2|Var3 a |b |c d |. |e . |f |g ; run;
Ksharp
data dummy; infile cards dlm='|'; input var1 : $char10. var2 : $char10. var3 : $char10.; if _n_ = 1 then delete; cards; Var1|Var2|Var3 a |b |c d |. |e . |f |g ; run;
Ksharp
Thank You
Your input statement is using "Formatted Input" (look it up). Formatted Input is incompatible with delimited data. You need to use "List Input" which is compatible. You can use an informat with list input by using the : modifier.
Something like this. Notice that $CHAR preserves leading spaces and read . as .; You might like $F10. which will read . as blank and left justify the values.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.