Hi every one,
below is type of data i am working on, and i need a little help , in fact i need to count or extract the animals those have only observation recorded from BHb Var. or recorded from two Var. BHB and MUn and also , three Var. BHB, MUN and Lac , same thing if an animal have only one observation fr only the 3rd var (LAc.
Thank guys , i appriciate your help.
Animal | BHB | MUN | Lac |
1 | 1 | 4 | |
2 | 1 | 5 | |
3 | 1 | 4 | 5 |
4 | 1 | 4 | 5 |
5 | 4 | ||
6 | 1 | 4 | 5 |
7 | 5 | ||
8 | 1 | 4 | 5 |
9 | 4 | 5 | |
10 | 1 | 5 |
Colors are hard to program. But numbers are easy.
data have;
input Animal BHB MUN Lac;
cards;
1 1 4 .
2 1 . 5
3 1 4 5
4 1 4 5
5 . 4 .
6 1 4 5
7 . . 5
8 1 4 5
9 . 4 5
10 1 . 5
;
data want;
set have;
group = 4*missing(BHB)+2*missing(MUN)+missing(Lac);
run;
Result
Obs Animal BHB MUN Lac group 1 1 1 4 . 1 2 2 1 . 5 2 3 3 1 4 5 0 4 4 1 4 5 0 5 5 . 4 . 5 6 6 1 4 5 0 7 7 . . 5 6 8 8 1 4 5 0 9 9 . 4 5 4 10 10 1 . 5 2
Or use the BINARY format to see how the numbers 0 to 7 are formed from the three bits.
proc print;
format group binary3.;
run;
Obs Animal BHB MUN Lac group 1 1 1 4 . 001 2 2 1 . 5 010 3 3 1 4 5 000 4 4 1 4 5 000 5 5 . 4 . 101 6 6 1 4 5 000 7 7 . . 5 110 8 8 1 4 5 000 9 9 . 4 5 100 10 10 1 . 5 010
Please show us the desired output from this example data set.
Hi Mr. Paige Miller
i need to identify each animal with each test are BHB , MUN or Lac, for example, following the type of color, animal 3 , 4 , 6 and 8 have the complete 3 tests. but 2 and 10 are tested only by BHB and lac.
So, i dont know if you have now an idea about my my desirable output data.
Thank you so much for your help.
AMEUR
data want;
set have;
category = n(bhb,mun,lac);
run;
Hi , Paige Miller , thank you for your reply.
Sorry its not working this give the whole number of tests without specify which test , for example using the table mentionned above, those animals have only two different test type . the code give me number 2 but i cant know which test is BHB with Lac or BHB with MUN.
Thank you so muhc
AMEUR
Colors are hard to program. But numbers are easy.
data have;
input Animal BHB MUN Lac;
cards;
1 1 4 .
2 1 . 5
3 1 4 5
4 1 4 5
5 . 4 .
6 1 4 5
7 . . 5
8 1 4 5
9 . 4 5
10 1 . 5
;
data want;
set have;
group = 4*missing(BHB)+2*missing(MUN)+missing(Lac);
run;
Result
Obs Animal BHB MUN Lac group 1 1 1 4 . 1 2 2 1 . 5 2 3 3 1 4 5 0 4 4 1 4 5 0 5 5 . 4 . 5 6 6 1 4 5 0 7 7 . . 5 6 8 8 1 4 5 0 9 9 . 4 5 4 10 10 1 . 5 2
Or use the BINARY format to see how the numbers 0 to 7 are formed from the three bits.
proc print;
format group binary3.;
run;
Obs Animal BHB MUN Lac group 1 1 1 4 . 001 2 2 1 . 5 010 3 3 1 4 5 000 4 4 1 4 5 000 5 5 . 4 . 101 6 6 1 4 5 000 7 7 . . 5 110 8 8 1 4 5 000 9 9 . 4 5 100 10 10 1 . 5 010
Its worked , perfectly , thank you TOM.
AMEUR
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: