全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2664 5
2011-03-25
悬赏 10 个论坛币 已解决
有这么个题目,数据库有73个变量,
每个变量代表某一个月的就业情况,就业情况,失业,临时工,长期工
总共有2000多个观察者,
然后老师要我们编个循环语句,要计算每个观察者分别在这三种情况得时间有多长.用一张表格表现出来

请问可以用array么????

求高手指点 谢谢

最佳答案

baoaibaobao 查看完整内容

a1 w2 t3 o4表示四个月的结业情况,其中的取值为1、2、3,分别代表失业,临时工,长期工。a b c d e代表5个观察者,b数据集中的b1表示失业的月份数,b2表示临时工月份数,b3表示长期工月份数。 最后的结果为 id b1 b2 b3 a 2 2 0 b 0 3 1 ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-3-25 07:40:20
复制代码
a1 w2 t3 o4表示四个月的结业情况,其中的取值为1、2、3,分别代表失业,临时工,长期工。a b c d e代表5个观察者,b数据集中的b1表示失业的月份数,b2表示临时工月份数,b3表示长期工月份数。
最后的结果为

                                     id    b1    b2    b3

                                     a      2     2     0
                                     b      0     3     1
                                     c      1     3     0
                                     d      4     0     0
                                     e      2     2     0
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-3-25 07:49:32
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-3-25 18:42:36
3# baoaibaobao

谢谢楼上的回复。。。。。
dm 'clear log; clear output';
libname lib 'D:\projet sas stata';
proc contents data=lib.INSERTION;run;
data lib.question1 ;
set lib.INSERTION;  
retain;
array a(63) SIT4V01 SIT4V02 SIT4V03 SIT4V04 SIT4V05 SIT4V06 SIT4V07 SIT4V08 SIT4V019 SIT4V10 SIT4V11 SIT4V12 SIT4V13 SIT4V14 SIT4V15 SIT4V16 SIT4V17 SIT4V18 SIT4V19 SIT4V20 SIT4V21 SIT4V22 SIT4V23 SIT4V24 SIT4V25 SIT4V26 SIT4V27 SIT4V28 SIT4V29 SIT4V30 SIT4V31 SIT4V32 SIT4V33 SIT4V34 SIT4V35 SIT4V36 SIT4V37 SIT4V38 SIT4V39 SIT4V40 SIT4V41 SIT4V42 SIT4V43 SIT4V44 SIT4V45 SIT4V46 SIT4V47 SIT4V48 SIT4V49 SIT4V50 SIT4V51 SIT4V52 SIT4V53 SIT4V54 SIT4V55 SIT4V56 SIT4V57 SIT4V58 SIT4V59 SIT4V60  SIT4V61  SIT4V62  SIT4V63;
chomage=0;
enploinonaide=0;
emploi_aide=0;
inactivite=0;
do i=1 to dim(a);
if a(i)=17 then chomage=chomage+1;
if a(i)=1 then enploinonaide=enploinonaide+1;
if a(i)=2 then enploinonaide=enploinonaide+1;
if a(i)=8 then enploinonaide=enploinonaide+1;
if a(i)=9 then enploinonaide=enploinonaide+1;
if a(i)=10 then enploinonaide=enploinonaide+1;
if a(i)=11 then enploinonaide=enploinonaide+1;
if a(i)=3 then emploi_aide=emploi_aide+1;
if a(i)=4 then emploi_aide=emploi_aide+1;
if a(i)=5 then emploi_aide=emploi_aide+1;
if a(i)=6 then emploi_aide=emploi_aide+1;
if a(i)=7 then emploi_aide=emploi_aide+1;
if a(i)=13 then emploi_aide=emploi_aide+1;
if a(i)=14 then emploi_aide=emploi_aide+1;
if a(i)=12 then inactivite=inactivite+1;
if a(i)=15 then inactivite=inactivite+1;
if a(i)=18 then inactivite=inactivite+1;
end;
keep chomage emploinonaide emploi_aide inactivite;
run;
proc print;run;

这是我按照你的方法,然后修改了一下。你看看什么地方应该改进的呢????
谢谢哦
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-3-25 18:43:01
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-3-25 19:02:58
哈哈,我知道怎么做了。。。。。。谢谢3楼啊
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群