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!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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