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

i have a data set containing the data of 365 days.

i want to extract the data of 1st of every month and last day of every month.

eg. if i have data of 3 months jan, feb,march then i want output data set to contain 1st jan, 31st jan, 1st feb, 28th feb, 1st march,31st march.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

something like:

 

data monthBegEnd;
set myData;
if date = intnx("month", date, 0, "beginning") or 
   date = intnx("month", date, 0, "end") then output;
run;
PG

View solution in original post

8 REPLIES 8
novinosrin
Tourmaline | Level 20

a simple intnx with begin and end option

 

would be nice if you posted sample of what you have and what you desire as output

anirudhs
Obsidian | Level 7

start_date value

1/1/2018 123
1/2/2018 124
1/3/2018 125
1/4/2018 126
1/5/2018 127
1/6/2018 128
1/30/2018 129
1/31/2018 130
2/1/2018 131
2/2/2018 132
2/3/2018 133
2/4/2018 134
2/27/2018 135
2/28/2018 136
3/1/2018 137
3/2/2018 138
3/3/2018 139
3/4/2018 140
3/5/2018 141
3/6/2018 142
3/7/2018 143
3/8/2018 144
3/29/2018 145
3/30/2018 146
3/31/2018 147
4/1/2018 148
4/2/2018 149
4/3/2018 150

Output Data B:
start_date value

1/1/2018 123
1/31/2018 130
2/1/2018 131
2/28/2018 136
3/1/2018 137
3/31/2018 147
4/1/2018 148

 

 

novinosrin
Tourmaline | Level 20

@PGStats code does that. 🙂

PGStats
Opal | Level 21

something like:

 

data monthBegEnd;
set myData;
if date = intnx("month", date, 0, "beginning") or 
   date = intnx("month", date, 0, "end") then output;
run;
PG
anirudhs
Obsidian | Level 7
will this extract the 1st day of all the months present in data set .??
PGStats
Opal | Level 21

It will extract all dates which are the first of the month or the last of the month. It will never select March 2, for example, even if March 1 is absent from your data.

 

Try it and see. Smiley Happy

PG
learsaas
Quartz | Level 8

sas learning

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
  • 8 replies
  • 1307 views
  • 0 likes
  • 5 in conversation