Dear All,
Can anyone help me with the below query ?
I have a dataset as below:
ID TIME SAMPLE TEST ID
101 1hour BLOOD
101 2 hour URINE
102 30min blood
103 30min blood
103 1 hour urine
103 2 hour blood
103 3 hour urine
For the above data i need to assign TESTID values as some test1, test2, test3 per ID, per TIME and per sample. Desired output is as below:
ID TIME SAMPLE TEST ID
101 1hour BLOOD TEST1
101 1hour BLOOD TEST2
101 1hour BLOOD TEST3
101 2 hour URINE TEST 1
101 2 hour URINE TEST 2
101 2 hour URINE TEST 3
102 30min blood TEST 1
102 30min blood TEST 2
102 30min blood TEST 3
103 30min blood TEST 1
103 30min blood TEST 2
103 30min blood TEST 3
103 1 hour urine TEST 1
103 1 hour urine TEST 2
103 1 hour urine TEST 3
103 2 hour blood TEST 1
103 2 hour blood TEST 2
103 2 hour blood TEST 3
103 3 hour urine TEST 1
103 3 hour urine TEST 2
103 3 hour urine TEST 3
data want;
set have;
test_id='ADB12PL';
output;
test_id='ADP13LM';
output;
test_id='DEF99SE';
output;
run;
data want;
set have;
do i=1 to 3;
test_id=cats('TEST',i);
output;
end;
run;
Thanks Miller,
But I have a doubt here..
what if there are some values like ADB12PL, ADP13LM, DEF99SE which are to be assigned for TEST ID instead of test1, test2 and test3 ?
@r3570 wrote:
what if there are some values like ADB12PL, ADP13LM, DEF99SE which are to be assigned for TEST ID instead of test1, test2 and test3 ?
Explain this, please. Show an example.
Output required as below:
ID TIME SAMPLE TEST ID
101 1hour BLOOD ADB12PL
101 1hour BLOOD ADP13LM
101 1hour BLOOD DEF99SE
101 2 hour URINE ADB12PL
101 2 hour URINE ADP13LM
101 2 hour URINE DEF99SE
102 30min blood ADB12PL
102 30min blood ADP13LM
102 30min blood DEF99SE
103 30min blood ADB12PL
103 30min blood ADP13LM
103 30min blood DEF99SE
103 1 hour urine ADB12PL
103 1 hour urine ADP13LM
103 1 hour urine DEF99SE
103 2 hour blood ADB12PL
103 2 hour blood ADP13LM
103 2 hour blood DEF99SE
103 3 hour urine ADB12PL
103 3 hour urine ADP13LM
103 3 hour urine DEF99SE
data want;
set have;
test_id='ADB12PL';
output;
test_id='ADP13LM';
output;
test_id='DEF99SE';
output;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.