BookmarkSubscribeRSS Feed
mantubiradar19
Quartz | Level 8

I have a time series data or repeated measurements collected over a time period. I have got the DATE variable. I would like to know how I can I subset this dataset into another dataset containing only the first and last series data based on the DATE variable?

4 REPLIES 4
Reeza
Super User

Please post some sample data and your expected output. 

ballardw
Super User

I have to assume that your date values are SAS date values for this to work AND assumng you have a cutoff date such that all value before  the date go to one set and after to the other.

Assume that the cutoff date is January 1 1016.

 

data FirstSeries LastSeries;

   set Have;

   if Date < '01JAN2016'd then output FirstSeries;

   else output LastSeries;

run;

 

If you have not used SAS date literal note that you have to express the date as 'ddMONyyyy'd. You can use single or double quotes but the quotes are required and the D at the end is what tells SAS to use the value as a date and not a simple string.

mantubiradar19
Quartz | Level 8

Hi there! Thank you. Say for example I have multiple observations for the year 2013. How I can I retain or make a separate dataset with the last observation from year 2012. My data varaible is in this form "22MARCH2013". 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 950 views
  • 0 likes
  • 3 in conversation