BookmarkSubscribeRSS Feed
BaalaRaaji
Quartz | Level 8

Hi there,

 

I am below dataset...just took one id as sample...

 

Datedate_histID_NUMBERBRANCH_NUMBERTERM_END_DATE
30Jun201830Jun2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201831May2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201830Apr2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201831Mar2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201828Feb2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201831Jan2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201831Dec2017 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201830Nov2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201831Oct2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201830Sep2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201831Aug2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201831Jul2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201830Jun2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201831May2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201830Apr2017 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Mar2017 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201828Feb2017 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Jan2017 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Dec2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201830Nov2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Oct2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201830Sep2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Aug2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201831Jul2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201830Jun2016 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201830Jun2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831May2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201830Apr2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831Mar2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201828Feb2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831Jan2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831Dec2017 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201830Nov2017 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831Oct2017 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201830Sep2017 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201831Aug2017 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201830Jun2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831May2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201830Apr2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831Mar2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201828Feb2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831Jan2018 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831Dec2017 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201830Nov2017 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831Oct2017 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201830Sep2017 0:00:00.00097621271026668427Jul2020 0:00:00.000
30Jun201831Aug2017 0:00:00.00097621271026668427Jul2020 0:00:00.000

 

 

I have to get the output as below...picking the different dates by id and branch_number ..

 

Datedate_histID_NUMBERBRANCH_NUMBERTERM_END_DATE
30Jun201830Jun2018 0:00:00.00097621271024414320Apr2020 0:00:00.000
30Jun201830Nov2017 0:00:00.00097621271024414317Apr2020 0:00:00.000
30Jun201830Apr2017 0:00:00.00097621271024414318Apr2017 0:00:00.000
30Jun201830Jun2018 0:00:00.00097621271026664127Jul2020 0:00:00.000
30Jun201830Jun2018 0:00:00.00097621271026668427Jul2020 0:00:00.000

 

any advice much appreciated...thanks

 

Regards,

RS

2 REPLIES 2
novinosrin
Tourmaline | Level 20
data want; set have; by id b_number date; if first.date; run; untested
ballardw
Super User

In SAS you want to be careful about the term "date". SAS will treat numeric values of the number of days since 1 Jan 1960 as dates with functions and supported formats. The values you show would be more likely datetime values as they show a time component. Datetime values are numbers of seconds.

 

The format you show the dates appearing as also use a MicroSlop format that SAS by default does not use for display. So I suspect that your variable is actually character which means that sort order is not going to work (30Apr will come before 30Jan).

You may wan to ensure the variable type and format used.

It is very worthwhile to have dates as SAS date values as then there are a large number of functions to manipulate the values, sort order is as expected for tables or graphs and you can create many summaries by changing formats for grouping without having to create additional variables for that purpose.

 

Also since NONE of the shown values have any significant time value you might be better off changing them to dates. Then the verbiage and appearance match.

 

 

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
  • 618 views
  • 0 likes
  • 3 in conversation