06-23-2017 11:28 AM
I'm having two single quote (') seprated by delimeter.
its is reading them as 1 and var3 is equal to "8" which should be var4 in second observation.
infile datalines dsd dlm='|';
proc print data=ds1;
Also I don't want to "~" before variable because in actual case I don't which two consuctive variable will contain single quotation.
Actual text which I'm trying to import from unix contains 200 variable and that is tab delimited.. I've given above example of pipe delimited just to more readable.
Please help me out !!
06-23-2017 12:48 PM
So if your input file never has null values then you can just drop the DSD option.
But if your input file has both null values (ie examples where two delimiters are right next to each other and it means there is value that empty) then you will need to process the data line before reading it.
So you could change the |'| into |"'"| so that SAS will see that the single quote is in fact a quoted string and so the DSD option will work.
input @; do while (index(_infile_,"|'|")); _infile_=tranwrd(_infile_,"|'|","|""'""|"); end; input var1-var5;
Or if you never have actual quoted string values that would also require the DSD option then perhaps you can drop the DSD option from the INFILE and instead convert the || into |.| to indicate a missing value.
input @; do while (index(_infile_,"||")); _infile_=tranwrd(_infile_,"||","|.|"); end; input var1-var5;
06-23-2017 04:32 PM
But my actual file is not pipe delimited it is tab delimeted... Here I've given example of pipe delimited just to get more understand.
So in the fix use tabs instead of pipe character. The hex code for a tab is '09'x.