BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
sas_
Fluorite | Level 6

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

3 REPLIES 3
Ksharp
Super User

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

sas_
Fluorite | Level 6

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

Ksharp
Super User

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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