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

Hi-

I'm stuck... I need to identify a sample of records spaced by 2 days beginning on 1 April 1968 and ending on 31 July 1974. My initial approach of taking the days 1,3,5... obviously doesn't work.

 

My dataset contains the date (SAS format) as well as the month, day and year as individual variables. Ideally I would like the following:

 

t_date      flag

3/1/1968   1

3/2/1968   0

3/3/1968   1

...

 

Thank you in advance for your help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
do date='01mar1968'd to '31jul1974'd;
flag=mod(date+1,2);
 output;
end;
format date date9.;
run;

View solution in original post

2 REPLIES 2
Ksharp
Super User
data have;
do date='01mar1968'd to '31jul1974'd;
flag=mod(date+1,2);
 output;
end;
format date date9.;
run;
Lyn2
Calcite | Level 5

Thank you, this worked perfectly!

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
  • 2 replies
  • 966 views
  • 0 likes
  • 2 in conversation