BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

Hi,

 

I'm trying to check the consistency of values of a variable across different timepoints. 

 

"Regular" records will have consistency checked for across all 5 timepoints. However, there are some special cases (based on the variable called timepoint) that should only look at CERTAIN timepoints rather than looping through all of them. 

 

Timepoint can represent a single timepoint or up to 2:

 

Timepoint

1

2

3

4

5

1, 2

2, 3

3, 4

4, 5

1, 3

etc. 

 

Essentially what I'd like to do is set up the do-loop so that the iteration is conditional and based on the value of timepoint, ie:

 

1. If timepoint is missing (regular record) do i = 1 to 5

2. If timepoint = 1, cycle through every timepoint EXCEPT timepoint 1 (so do i = 2 to 5). 

 

Any help is much appreciated. 

 

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @Walternate,

 

You can use the CONTINUE statement to "skip" the values in TIMEPOINT:

data have;
input timepoint $4.;
cards;
.
1
2
3
4
5
1, 2
2, 3
3, 4
4, 5
1, 3
;

data want;
set have;
do i=1 to 5;
  if findw(timepoint,put(i,1.)) then continue;
  /* more code to "check the consistency of values" */
  output; /* <-- just as an example */
end;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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