data nums; infile datalines dsd delimiter='ab'; input X Y Z; datalines; 1aa2ab3 4b5bab6 7a8b9 ;
run;
Output:
The SAS System OBS X Y Z 1 1 . 2 2 4 5 . 3 7 8 9
In the DELIMITER= statement you specify list of individual delimiters, in this example you have two individual delimiters a and b.
The question now is, What if we have two or more consecutive delimiters? You have two cases for that:
1- DELIMITER= alone
Any combination of consecutive delimiter are treated as only one delimiter. So if you deleted the statment DSD in the infile statment from your example.
In the dataset example: 1aa2ab3
will be treated as: 1 aa 2 ab 3
as if
1,2,3
2- DELIMITER= with DSD
Consecutive delimiters are treated individually even if they are consecutive.
In the dataset example: 1aa2ab3
will be treated as: 1 a Missing a 2 a Missing b 3
as if
1, , 2, , 3
This example is explained here:
I have read that. I did not understand it.
In the DELIMITER= statement you specify list of individual delimiters, in this example you have two individual delimiters a and b.
The question now is, What if we have two or more consecutive delimiters? You have two cases for that:
1- DELIMITER= alone
Any combination of consecutive delimiter are treated as only one delimiter. So if you deleted the statment DSD in the infile statment from your example.
In the dataset example: 1aa2ab3
will be treated as: 1 aa 2 ab 3
as if
1,2,3
2- DELIMITER= with DSD
Consecutive delimiters are treated individually even if they are consecutive.
In the dataset example: 1aa2ab3
will be treated as: 1 a Missing a 2 a Missing b 3
as if
1, , 2, , 3
Thanks a lot!!
What part don't you understand?
Things you should understand:
1. What are the delimiters?
2. What does the DSD option do?
Try the code with the above removed and variations on the DLM to help figure out what's going on.
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 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.