data have;
infile datalines dlm='{''^''}' missover;
input id name $ salary;
datalines;
{^}{^}55000
{^}rohit{^}
3{^}giridhar{^}
;
run;
it has work when all columns has data but above scenario it won't work
help me out thanks in advance
Use DLMSTR not DLM and add the DSD option.
In DLM each character is treated as an individual delimiter, i.e. you have 4 delimiters, " , {, }, ^
DLMSTR used the group of characters as a single delimiter.
I don't think you need the quotes in there unless your delimiter includes quotes, which it doesn't in your example data.
Make sure your example data reflects your actual data as much as possible, because we can't see it.
Use DLMSTR not DLM and add the DSD option.
In DLM each character is treated as an individual delimiter, i.e. you have 4 delimiters, " , {, }, ^
DLMSTR used the group of characters as a single delimiter.
I don't think you need the quotes in there unless your delimiter includes quotes, which it doesn't in your example data.
Make sure your example data reflects your actual data as much as possible, because we can't see it.
As Reeza has stated, instead of DLM, you need DLMSTR and DSD, in your example as follows:
infile datalines dlmstr='{^}' dsd missover ;
I think that your question is really how to use a multiple character string as the delimiter when reading text from a file.
If you want a specific sequence of characters to be the delimiter then you need to use the DLMSTR= option on the INFILE statement.
If you specify multiple characters in the DLM= option each individual character is treated as a delimiter. So '{^}' is not one delimiter but three of them next to each other.
The reason it properly read the lines did not have any empty values is because you did not include the DSD option. Without the DSD option adjacent delimiters do not indicate a missing value. So having three delimiters between each value did not mean there were two missing values. But you need the DSD option to distinguish which values are missing when not all values are present, like in your example.
data have;
infile datalines dsd dlmstr='{^}' truncover;
input id name $ salary;
datalines;
{^}{^}55000
{^}rohit{^}
3{^}giridhar{^}
;
PS. Don't include quotes in the DLMSTR value unless they are actually part of the string.
PS. Get in the habit of using the TRUNCOVER instead of MISSOVER option. They generally work the same, but most of the time you will want the input to read the characters it can find instead of giving you a missing value.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.