BookmarkSubscribeRSS Feed
HTG
Calcite | Level 5 HTG
Calcite | Level 5

 Hi, I am writing the below mentioned codes to churn out results from a data set with a specific date range. I set the date as 15dec2015 to get results for 01dec2015 to 31dec2015. The majority of the churned result are from dec2015 but consists some of the earlier result from 2012 to Nov 2015. Can you advise on how I can get the churned results only from dec2015? Below is the code:

 

libname mis_data "E:\GCC Data Mart\Monthly MIS\Unsecured\FE_Deck\Data"

 

%let setdt='15DEC2015'd;

 

data _null_;

curr=intnx('month',&setdt,0);

curr=intnx('day',curr,-1);

   

call symput("yymm",put(curr,yymmn4.));

call symput("yyyymmdd",put(curr,yymmddn8.));

call symput("dt",compress("'"||put(curr,date9.)||"'"||"d"));

run;

 

%put &yymm &yyyymmdd &dt;

3 REPLIES 3
Reeza
Super User

You need to show your filter as well. How you use the macro variables matters. 

PGStats
Opal | Level 21

Assuming your data includes a SAS date variable (say myDate), all you need is to add the statement

 

where myDate between intnx("MONTH", &setdt, 0, "BEGINNING") and intnx("MONTH", &setdt, 0,"END");

 

to your data step, or the clause

 

where myDate between intnx("MONTH", &setdt, 0, "BEGINNING") and intnx("MONTH", &setdt, 0,"END")

 

to your SQL query.

 

If your date variable is a SAS datetime, replace "MONTH" by "DTMONTH".

PG
HTG
Calcite | Level 5 HTG
Calcite | Level 5

Thanks PG.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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