BookmarkSubscribeRSS Feed
Shyamkumar
Calcite | Level 5

Hi,

 

I have a list of dates with Level and location wise,so i want require dates between below dates.Please help out.

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

So DT is equal to 02OCT... in your fist obs and 06OCT... in the second obs. You then want three observations in between with the 3. 4. and 5. oft Oct, correct?

Shyamkumar
Calcite | Level 5
yes sir
PeterClemmensen
Tourmaline | Level 20

Ok. Do you have a SAS/ETS license?

PeterClemmensen
Tourmaline | Level 20

Here is one way

 

data have;
input LEVEL1 $ LOCATION_PL_EMP_MASTER $ 7-16 DT :datetime17.;
format DT datetime17.;
infile datalines4 dlm='|';
datalines;
India|Hyderabad |02Oct2019 0:00:00
India|Hyderabad |06Oct2019 0:00:00
India|Hyderabad |08Oct2019 0:00:00
India|Hyderabad |13Oct2019 0:00:00
India|Mumbai    |02Oct2019 0:00:00
India|Mumbai    |03Oct2019 0:00:00
India|Mumbai    |04Oct2019 0:00:00
India|Mumbai    |05Oct2019 0:00:00
India|Mumbai    |06Oct2019 0:00:00
India|Mumbai    |08Oct2019 0:00:00
India|Mumbai    |10Oct2019 0:00:00
India|Mumbai    |11Oct2019 0:00:00
India|Mumbai    |12Oct2019 0:00:00
India|Mumbai    |13Oct2019 0:00:00
India|Mumbai    |14Oct2019 0:00:00
India|Mumbai    |15Oct2019 0:00:00
India|Mumbai    |16Oct2019 0:00:00
India|Mumbai    |17Oct2019 0:00:00
India|Pune      |02Oct2019 0:00:00
India|Pune      |06Oct2019 0:00:00
India|Pune      |07Oct2019 0:00:00
India|Pune      |08Oct2019 0:00:00
India|Pune      |11Oct2019 0:00:00
India|Pune      |12Oct2019 0:00:00
India|Pune      |13Oct2019 0:00:00
India|Vijayawada|02Oct2019 0:00:00
India|Vijayawada|03Oct2019 0:00:00
India|Vijayawada|06Oct2019 0:00:00
India|Vijayawada|08Oct2019 0:00:00
India|Vijayawada|13Oct2019 0:00:00
;

data want(drop=_:);
    do until (last.LOCATION_PL_EMP_MASTER);
        set have;
        by LOCATION_PL_EMP_MASTER notsorted;
        if first.LOCATION_PL_EMP_MASTER then _from=DT;
        if last.LOCATION_PL_EMP_MASTER  then _to=DT;
    end;

    do DT=_from to _to by 86400;
        output;
    end;
run;
andreas_lds
Jade | Level 19

Please post data in usable form and the expected result with that data.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1051 views
  • 0 likes
  • 3 in conversation