Hello
In the following examples there are columns (char) with delimiter.
Why the data sets are not created well?
data example1;
infile datalines dlm="|" dsd;
input var1 $ ;
datalines;
ABC|2015|XYZ
ABC||XYZ
;
run;
data example2;
input var1 $ ;
datalines;
ABC,2015,XYZ
ABC,XYZ
;
run;
What did you expect from this code? What is your desired result?
Look at the values in the data set that was created.
Do you see that the values are not matched to values that I entered
If the char used a delimiter between variable can appear in char variables as content, then that content has to be enclosed in quotes. If it is not quoted, return the file to the one who created it, explaining that such garbage could be processed, but requires more time to write the code and requires additional to verify the result.
You have 3 variables per row, then change your code to:
data example1;
informat var1-var3 $5.;
infile datalines dlm="|" dsd;
input var1 var2 var3 ;
datalines;
ABC|2015|XYZ
ABC||XYZ
;
run;
What output do you want?
Your current programs are just reading the first value from the data lines.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.