DATA Step, Macro, Functions and more

Reg:The Dates to move day if job Runs

Accepted Solution Solved
Reply
Contributor
Posts: 66
Accepted Solution

Reg:The Dates to move day if job Runs

data calendar_table(drop=sdt edt);
input sdt$ 1-9 edt$ 10-20;
stdate =input(sdt,date9.);
enddate=input(edt,date9.);
format stdate enddate ddmmyy10.;
cards;
12jan2011 13jan2011
13jan2011 14jan2011
14jan2011 15jan2011
15jan2011 16jan2011
16jan2011 17jan2011
17jan2011 18jan2011
run;
proc print;
run;


see actually in the above table i have the dates on which the loading to be happened

In the second table in one cell i will have the Sdate and Edate so i want one table
with one obs of date so that

Ex:
Table 2
Sdate         Edate        Path      Data            Fpath
12012011    13012011   c/raw/    order.txt      c/raw/12012011/order.txt

I want the dates  to go to another table in the Infile path of the job i will
give Fpath in the macro so that it will take data from there daily

if the job again runs the date should increment so i will run for 13 date this is my aim
for the loading data based on date

Sdate         Edate        Path      Data            Fpath


13012011    14012011   c/raw/    order.txt      c/raw/13012011/order.txt


Accepted Solutions
Solution
‎12-26-2011 04:44 AM
Contributor
Posts: 66

Re: Reg:The Dates to move day if job Runs

Small need if indicator and  is there  it should move the dates having indicaotr=1 and No=2 only how can i do it

data calendar_table(drop=sdt edt);

input sdt$ 1-9 edt$ 10-20 Indicator NO;

stdate =input(sdt,date9.);

enddate=input(edt,date9.);

format stdate enddate ddmmyy10.;

cards;

12jan2011 13jan2011 1 2

13jan2011 14jan2011 1 4

14jan2011 15jan2011 2 3

15jan2011 16jan2011 1 4

16jan2011 17jan2011 1 4

17jan2011 18jan2011 2 5

;

run;

data calendar_table need_table;

set calendar_table;

length path data $ 400;

if indicator=1 and no=4 then do;

          path='c:\raw';data='order.txt';

          output need_table;delete;end;

output  calendar_table;

run;

Req:2 )And i wnat to Edit the need_table and keep the dates if dates 12jan2011 13jan2011  are complted if needed i should call them again as per the logic the calendar_table does not hold these obs if once the date was crossed ,how can i do that.

Reg:3) If  need_table; are having dates sdate :15jan2011 and endate:16jan2011 dates in that table i will edit them and again move the date  to 13jan2011 and 14jan2011 respectively again it should get the dates accordingly ...

Thqs in advance

View solution in original post


All Replies
Super User
Posts: 9,671

Reg:The Dates to move day if job Runs

Using simple code can get that.

data calendar_table(drop=sdt edt);
input sdt$ 1-9 edt$ 10-20;
stdate =input(sdt,date9.);
enddate=input(edt,date9.);
format stdate enddate ddmmyy10.;
cards;
12jan2011 13jan2011
13jan2011 14jan2011
14jan2011 15jan2011
15jan2011 16jan2011
16jan2011 17jan2011
17jan2011 18jan2011
;
run;

data calendar_table need_table;
 set calendar_table;
 length path data $ 400;
 if _n_ eq 1 then do;
          path='c:\raw';data='order.txt';
          output need_table;delete;end;
 output  calendar_table;
run;

Ksharp

Solution
‎12-26-2011 04:44 AM
Contributor
Posts: 66

Re: Reg:The Dates to move day if job Runs

Small need if indicator and  is there  it should move the dates having indicaotr=1 and No=2 only how can i do it

data calendar_table(drop=sdt edt);

input sdt$ 1-9 edt$ 10-20 Indicator NO;

stdate =input(sdt,date9.);

enddate=input(edt,date9.);

format stdate enddate ddmmyy10.;

cards;

12jan2011 13jan2011 1 2

13jan2011 14jan2011 1 4

14jan2011 15jan2011 2 3

15jan2011 16jan2011 1 4

16jan2011 17jan2011 1 4

17jan2011 18jan2011 2 5

;

run;

data calendar_table need_table;

set calendar_table;

length path data $ 400;

if indicator=1 and no=4 then do;

          path='c:\raw';data='order.txt';

          output need_table;delete;end;

output  calendar_table;

run;

Req:2 )And i wnat to Edit the need_table and keep the dates if dates 12jan2011 13jan2011  are complted if needed i should call them again as per the logic the calendar_table does not hold these obs if once the date was crossed ,how can i do that.

Reg:3) If  need_table; are having dates sdate :15jan2011 and endate:16jan2011 dates in that table i will edit them and again move the date  to 13jan2011 and 14jan2011 respectively again it should get the dates accordingly ...

Thqs in advance

Super User
Posts: 9,671

Re: Reg:The Dates to move day if job Runs

For your situation, I think you can use CALL EXECUTE statement to perform your job.

Firstly make a macro to include what you need to do. then use

if indicaotr=1 and No=2 then call execute('%myjob('||stdate||','||enddate);

Ksharp

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 181 views
  • 3 likes
  • 2 in conversation