Hi,
I have following data to read into SAS.
ID animal ID datum1 diagnose1 diagnose2 diagnose3 datum2
34204 1002031979 30.01.2017 2 4 3 . 33107 1001106236 16.01.2013 2 4 3 . 33107 1001655944 29.03.2013 1 13 . . 33107 1001706748 05.04.2013 1 13 . . 33107 1001555944 23.05.2013 1 13 . . 33107 1001886460 13.06.2013 1 13 . . 33107 1001607961 02.07.2013 1 13 . 04.02.2016 33107 1001531694 05.10.2013 1 13 . . 33107 1000886460 30.04.2014 1 13 . . 33107 1001555906 30.04.2014 1 13 . .
I have IDs and animal IDs. For ever animal I have datums where the animal was treated by the vet and the diagnose1,2,3 tells me what kind of disease that animal had.
Now I want to read it into SAS. But the problem is the datum.
Here how it looks when I read it into SAS:
ID animal ID datum1 diagnose1 diagnose2 diagnose3 datum2 34204 1002031979 20849 . 2 . . 33107 1001106236 19374 . 2 . . 33107 1001655944 19446 . 1 . . 33107 1001706748 19453 . 1 . . 33107 1001555944 19501 . 1 . . 33107 1001886460 19522 . 1 . . 33107 1001607961 19541 . 1 13 . 33107 1001531694 19636 . 1 . . 33107 1000886460 19843 . 1 . . 33107 1001555906 19843 . 1 . .
That the datum is now a number so SAS can work/count with it is ok but next column should be like the table above.
My SAS Code is this
data want;
infile 'have';
dsd missover delimiter = ';';
input
id
animal id
datum_1 DDMMYY8.
Diagnose_1
Diagnose_2
Diagnose_3
datum_2 DDMMYY8. ;
run;
Can anyone imagine what the problem could be?
Show the log from when you run that data step.
The code you show cannot generate the output shown as
data want; infile 'have'; dsd missover delimiter = ';'; input id animal id <= This ID would read the third column into the variable ID datum_1 DDMMYY8. Diagnose_1 Diagnose_2 Diagnose_3 datum_2 DDMMYY8. ; run;
Your informat is incorrect for datum1 and datum2, you want ddmmyy10. (count the number of characters) .
Also since your code shows a delimiter of ; it may help to post a few rows of data into a code box as your example input does not match your code either.
Best practice is to paste the data and log into a code box opened using the forum's {I} icon to preserve any messages or error text formatting.
Looks like you forgot to attach a format to your date variables. So SAS is displaying the internal representation of the dates, which is number of days since 01JAN1960. Just add a FORMAT statement to your data step.
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.