BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

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)).

  • Period 1 = Visit 200s
  • Period 2 = Visit 300s
  • Period 3 = Visit 400s
  • Period 4 = Visit 500s

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;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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);
--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

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);
--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 288 views
  • 0 likes
  • 2 in conversation