最近的选举要求以邮递方式发送党派信息手册包。我们想确定向一个选民中的50,000个注册选民分发这些广告材料花了多少工时。
每个人可以携带100册小册子,起初他们可以以1 m / s的速度行走,但是每次交付时它们的速度会加快0.01 m / s,最高为1.8 m / s。 在SAS中创建带有20次迭代的循环语句,该循环语句将:
a> 1.如果平均交货间隔为50 m,则显示每次交货的速度增加和每个人的行进距离。确保每次迭代都显示在结果表中。
b>使用另一个代码步骤来确定交付全部100册小册子所花费的总时间,以及交付给所有50,000名选民所需的时间。提示速度=距离/时间。
下面是1 a和b的代码。
data q6;
speed =1;
do i = 1 to 20;
distance_in_meters +50;
speed+0.01;
bundles+100;
output;
end;
run;
data q6;
speed=1;
do i = 1 to 1000 until (speed>=1.8);
distance_in_meters + 50 ;
speed + 0.01;
bundles +100;
output;
end;
run;
我需要b的帮助
答案 0 :(得分:0)
老师的一些模糊的问题说明。
这需要多长时间
有时是技巧性问题,人们用总的工时回答,而不是想要的技巧性回答,而是经过时间。
对于第二部分,您需要在调整速度之前计算每个投放时间(time = 50 / speed)
,并累积(total_time + time)
例如:
--- LOG ---
Time (hms) per person to deliver 100 pamphlets: 0:58:26
Number of pamplets: 50000
Number of persons: 500
Total person time (hms) on delivery: 486:53:34
Time to deliver all items if all people start at same time: 0:58:26
%let ItemCount = 50000;
%let ItemsPerPerson = 100;
%let LoadedVelocity = 1; * m/s;
%let UnloadDistance = 50; * m;
%let UnloadVelocityIncrease = 0.01; * m/s;
%let VelocityMax = 1.8; * m/s;
data want_a1_perPerson;
length index speedup distance speed 8.;
speed = 1;
distance = 0;
do index = 1 to 20;
* unload;
speedup = ifn (speed < &VelocityMax, &UnloadVelocityIncrease, 0);
speed + speedup;
distance + &UnloadDistance;
output;
end;
run;
data want_a2_perPerson;
length index speedup distance speed load unloaded 8.;
speed = 1;
distance = 0;
load = 100;
unloaded = 0;
do index = 1 by 1 until (speed >= &VelocityMax or load = 0);
unloaded + 1;
load + -1;
speedup = ifn (speed < &VelocityMax, &UnloadVelocityIncrease, 0);
speed + speedup;
distance + &UnloadDistance;
output;
end;
run;
data want_b;
length index speedup distance speed load unloaded 8.;
speed = 1;
distance = 0;
load = 100;
unloaded = 0;
do index = 1 by 1 until (load = 0);
distance + &UnloadDistance;
time_to_unload = &UnloadDistance / speed; * unit analysis: m / (m/s) = s;
total_time + time_to_unload;
unloaded + 1;
load + -1;
speedup = ifn (speed < &VelocityMax, &UnloadVelocityIncrease, 0);
speed + speedup;
output;
end;
personCount = &ItemCount / &ItemsPerPerson;
personHours = personCount * total_time;
putlog "Time (hms) per person to deliver 100 pamphlets: " total_time time7.;
putlog "Number of pamplets: &ItemCount";
putlog "Number of persons: " personCount;
putlog "Total person time (hms) on delivery: " personHours time9.;
putlog "Time to deliver all items if all people start at same time: " total_time time7.;
run;