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?
... View more
I want to count the answers (don't want a new variable) Var1: 1000 persons (ID) answered 1(yes) and 1500 2(no). same for Var2 I could do it with proc freq but I have a lot of double or multiple ID's and I just want one oberservation per ID.
... View more
Hi I have the following data id var1 var2 10 1 2 10 1 2 10 1 2 10 1 2 15 2 2 15 2 2 15 2 2 16 1 1 16 1 1 16 1 1 16 1 1 I want to count how many ID`s "said" var1 and var2 but I want to have just one observation per ID. How I can do this easily? With proc freq I get which Id said was but I want like 1000 ID's said var1 is 1 and var2 is 1,....
... View more
Thank you all! I have now the solution! I used: data want; set have; by tiernummer jahr; if first.jahr then zkz = max(zkz_lakt1_2_neu, zkz_lakt2_3_neu, zkz_lakt3_4_neu, zkz_lakt4_5_neu, zkz_lakt5_6_neu, zkz_lakt6_7_neu, zkz_lakt7_8_neu, zkz_lakt8_9_neu); run; Worked well!
... View more
I tried the array. Still not working. It just gives me zkz for first animal ID but I need for the first animal ID in a year the zkz. and if laktnr 1 is should take from zkz1_2 to zkz.
... View more
Hi, I have a problem. I have the following data animal ID laktnr year zkz1_2 zkz2_3 zkz3_4 zkz4_5 100 1 2015 400 100 1 2015 400 100 3 2016 430 100 3 2016 430 100 4 2017 390 101 2 2015 405 101 2 2015 405 101 4 2017 500 200 1 2015 390 200 1 2015 390 200 1 2015 390 200 3 2017 420 I want to create a new variable 'zkz' that shows the zkz for every animal just once per year. If laktnr is 1 then it should write the content from zkz1_2 into new variable zkz. If laktnr is 3 then it should write the content from zkz3_4 into zkz. animal ID laktnr year zkz1_2 zkz2_3 zkz3_4 zkz4_5 zkz(new variable) 100 1 2015 400 400 100 1 2015 400 100 3 2016 430 430 100 3 2016 430 100 4 2017 390 390 101 2 2015 405 450 101 2 2015 405 101 4 2017 500 500 200 1 2015 390 390 200 1 2015 390 200 1 2015 390 200 3 2017 420 420 I have no idea to solve the problem. Hope someone knows how to do it! Thank you!
... View more