I want the 100th place of the visit number to correspond with the PERIOD number, where period is based on the subject's individual timeline rather than the study timeline (e.g. Subject B joins the study during second round of drug administration (VISHAVE 300s). Since this drug and follow-up period would be Subject B's first, it counts as Period 1 (VISWANT 200s)).
I essentially want to make sure each visit number starts with the associated period number + 1. I figured the easiest way would be to save the last two digits as a temporary variable and then add (period+1)*100.
e.g. VISHAVE = 312 and PERIOD = 1, then TMP = 12
VISWANT = (PERIOD+1)*100 + TMP = (2)*100 + 12 = 212
Is there a way to only keep a value up to the tenth place?
data visits;
input id period vishave viswant @@;
cards;
1 1 200 200 1 1 201 201
1 2 300 300 1 2 301 300
1 3 400 400
2 1 200 200 2 1 201 201
2 2 400 300 2 2 402 302
2 3 500 400 2 3 501 401
3 1 300 200 3 1 301 201 3 1 306 206
4 2 500 300 4 2 503 303
;
run;
Is there a way to only keep a value up to the tenth place?
I assume you mean that if the value is 304, then you want 4. If the value is 312 then you want 12. Am I correct? (If not, explain more clearly and give examples of "Is there a way to only keep a value up to the tenth place?")
Use the MOD function
wanted_variable = mod(period,100);
Is there a way to only keep a value up to the tenth place?
I assume you mean that if the value is 304, then you want 4. If the value is 312 then you want 12. Am I correct? (If not, explain more clearly and give examples of "Is there a way to only keep a value up to the tenth place?")
Use the MOD function
wanted_variable = mod(period,100);
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.