Basically my question is how to understand "DSD" "COLON MODIFIER", because I'm facing with some problems when importing a txt file here are my raw data, experiment codes 1-4 and their results. 1. My raw data is like (in a txt file names t24.txt as an attachment) Susan*12/29/1970*10
Michael**6 2. The following output is desired: Obs employee bdate years
1 Susan 4015 10
2 Michael . 6 3. experiment codes 1-4 and their results I tried different codes to solve this problem (from CODE1-4 as follows), and I feel confused about the results. data t24ex1; /* CODE1 */
infile "&path/t24.txt" dsd dlm='*';
input employee $ bdate mmddyy10. years $;
run;
data t24ex2; /* CODE2 */
infile "&path/t24.txt" dlm='*';
input employee $ bdate mmddyy10. years $;
run;
data t24ex3; /* CODE3 */
infile "&path/t24.txt" dlm='*';
input employee $ bdate :mmddyy10. years $;
run;
data t24ex4; /* CODE4 */
infile "&path/t24.txt" dsd dlm='*';
input employee $ bdate :mmddyy10. years $;
run; results: 4. My confusion as far as I know, 1) DSD can treat 2 consecutive separators as one missing value e.g. a,b,,c => a,b,missing value,c 2) COLON can stop until meeting the next one separator e.g. My dog Sam Breed:Rottweiler Vet Bills: $478 (raw data)
INPUT @' Breed:' DogBreed $20.; -----> Rottweiler Vet Bill
INPUT @'Breed:' DogBreed : $20.; -----> Rottweiler So when I used CODE1, I was like assuming the dataset would become "Susan", "12/29/1970"(=4015), and "10"
"Michael", .(missing), "6" but it didn't work in this way, actually the result of the first row was Susan 4015 . And it didn't generate the result of the second row because of an error in log: NOTE: LOST CARD.
employee=Michael bdate=. years= _ERROR_=1 _N_=2 Even though the problem of the second row could be solved by adding a COLON modifier(as CODE4), I couldn't understand how it worked ... My environment is sas studio. Thank you for your time, I'm a beginner for SAS, it must be that I have a misunderstanding of SAS, I would be very grateful if you could point it out😘
... View more