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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.