Hello!,
I am interested to calculate how many weeks to finish a job
The file has job assigned date and completed date . I have matched up with weeks table to find the week the job was assigned and week it is completed.
For example, if the job was assigned in week 16 and completed in week 21 then I would want to find all weeks it is in process, then I will count each week how many are in process and put that number in a graph showing progress.
I am looking to pull data from week 16 to 32.
Please help .
Hi:
Since the ultimate request is for a graph, I wonder whether the second DATA step is needed. You could do everything in one DATA step program and then just use PROC SGPLOT for the graph.
Cynthia
data testdata;
infile datalines dlm=',' dsd;
input R_ID assign : date9. survey $ complete : date9.;
wk_id = week(assign);
assign_wk = week(assign);
comp_wk = week(complete);
num_wks= (comp_wk - assign_wk) + 1;
do i = assign_wk to comp_wk by 1;
plot_week = i;
output;
end;
label plot_week = 'Week';
return;
datalines;
101, 03mar2014, aaa, 18apr2014
110, 11apr2014, aaa, 08may2014
202, 18feb2014, aaa, 03apr2014
330, 12feb2014, aaa, 12apr2014
404, 01mar2014, aaa, 07apr2014
550, 13jan2014, bbb, 06may2014
606, 24apr2014, bbb, 12jun2014
770, 21mar2014, bbb, 15may2014
808, 28feb2014, bbb, 07may2014
990, 01may2014, bbb, 12may2014
;
run;
ods pdf file='c:\temp\plot_week.pdf';
proc sgplot data=testdata;
title 'See Number of Projects Each Week';
vbar plot_week /datalabel group=plot_week;
run;
ods pdf close;
Virus scanning seems to be taking a long time these days, perhaps consider embedding the data in your question.
Without seeing anything, I'd expand your data so that you have a record for each week for each project. Then you can summarize and graph from that data more easily.
data have;
input project $ week_start week_have;
cards;
A 23 41
B 21 27
C 34 45
D 1 14
;
run;
data expand;
set have;
do week=week_start to week_have;
output;
end;
run;
Hi:
Since the ultimate request is for a graph, I wonder whether the second DATA step is needed. You could do everything in one DATA step program and then just use PROC SGPLOT for the graph.
Cynthia
data testdata;
infile datalines dlm=',' dsd;
input R_ID assign : date9. survey $ complete : date9.;
wk_id = week(assign);
assign_wk = week(assign);
comp_wk = week(complete);
num_wks= (comp_wk - assign_wk) + 1;
do i = assign_wk to comp_wk by 1;
plot_week = i;
output;
end;
label plot_week = 'Week';
return;
datalines;
101, 03mar2014, aaa, 18apr2014
110, 11apr2014, aaa, 08may2014
202, 18feb2014, aaa, 03apr2014
330, 12feb2014, aaa, 12apr2014
404, 01mar2014, aaa, 07apr2014
550, 13jan2014, bbb, 06may2014
606, 24apr2014, bbb, 12jun2014
770, 21mar2014, bbb, 15may2014
808, 28feb2014, bbb, 07may2014
990, 01may2014, bbb, 12may2014
;
run;
ods pdf file='c:\temp\plot_week.pdf';
proc sgplot data=testdata;
title 'See Number of Projects Each Week';
vbar plot_week /datalabel group=plot_week;
run;
ods pdf close;
Thank you very much.
I think this code will work . I will give this a try
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.