I have a data set that has
ID spe1 test1 result1 spe2 test2 result2 spe3 test3 result3 spe4 test4 result4 spe5 test5 result5 spe6 test6 result6 spe7 test7 result7
1 ur cul neg thr cul pos rec Nat neg
2 ur cul neg rec Nat neg
3 thr cul pos
4 ur cul neg rec Nat neg thr cul pos
5 rec cul pos thr cul pos
6 rec Nat neg ur cul neg thr cul pos rec Nat neg
7 rec Nat pos ur cul neg thr cul pos cvx Nat neg
7 rec Nat pos ur cul neg thr cul pos cvx Nat neg urt cul neg
I would like to know number of tests conducted for each ID and number of Spe collected and number of pos result for each ID. How do i create a separate column of number of spe number of tests and number of pos result by speciemn
Please help
Please post the result you expect from the data you have posted.
The function cmiss returns the number of variables with missing value. If the number of variables is always 7, something like
count_spe = 7 - cmiss(of spe1-spe7);
should give you the number you want.
Please post the result you expect from the data you have posted.
The function cmiss returns the number of variables with missing value. If the number of variables is always 7, something like
count_spe = 7 - cmiss(of spe1-spe7);
should give you the number you want.
If you are creating this data set, and you have a choice, I would create it vertically rather than horizontally. This makes most analyses much simpler, and probably can be done using PROC FREQ.
Something like this:
ID SEQUENCE SPE TEST RESULT 1 1 ur cul neg 1 2 thr cul pos
Even better yet, result could be 0 (negative) or 1 (positive) instead of neg or pos.
If you are receiving the data in the wide format you showed, I would make the effort to transpose it to the long format to make things easier.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.