楼主: l6397
3236 6

[求助]高人:读取观察值的程序 [推广有奖]

  • 0关注
  • 0粉丝

博士生

42%

还不是VIP/贵宾

-

威望
0
论坛币
120 个
通用积分
16.6418
学术水平
1 点
热心指数
6 点
信用等级
0 点
经验
3788 点
帖子
235
精华
0
在线时间
178 小时
注册时间
2007-3-28
最后登录
2023-5-13

楼主
l6397 发表于 2008-1-5 22:13:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

高人:

     下列一组数据: 

 1 . . 1 . . 1 1 . 1 . . . . 1

1、怎样编程,来统计1出现的次数(按竖行输出下列形式) 

 1 . . 2 . . 3 4 . 5 . . . . 6

2、怎样编程,数字1的间隔次数(按竖行输出下列形式) 

 . . 2 . . 2 . . 1 . . . . 4 .

 求助高手帮我。       谢谢!!

二维码

扫码加我 拉你入群

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

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

关键词:怎样编程 求助高手 求助 程序 高人 观察

回帖推荐

yzhouwen 发表于6楼  查看完整内容

Thanks for the reminder, I modified the code a little bit, looks little better.data one;    input x @@;      cards;       1 2 1 1 0 0 2 1 1 8;  data two;      set one;       retain j 0;       do i=1 to _N_;    &n ...

yzhouwen 发表于4楼  查看完整内容

proc iml;/*the following program replace the jth 1 in a vector A by j */  A={1 1 0 6 1 0 1}; /* an other example*/   len=ncol(A);    j=0;            /* j denotes the jth 1 in A;*/   do i=1 to len;  /*A dnotes the ith element of A;*/       if A=1 the ...

yzhouwen 发表于3楼  查看完整内容

proc iml; iml;/*the following program replace the jth 1 in a vector A by j */A={1 1 0 6 1 0 1};len=ncol(A);j=0; /* j denotes the jth 1 in A;*/1 1 0 6 1 0 1};len=ncol(A);j=0; /* j denotes the jth 1 in A;*/0; /* j denotes the jth 1 in A;*/do i=1 to len; /*A dnotes the ith element of A;*/do i=1 to len; /*A dnotes the ith element of A;*/if A=1 then do;j=j+1;A ...

本帖被以下文库推荐

沙发
monkeyxu1983 发表于 2008-1-6 19:57:00
无能为力

藤椅
yzhouwen 发表于 2008-1-7 06:22:00

proc iml;

iml;

/*the following program replace the jth 1 in a vector A by j */

A={1 1 0 6 1 0 1};

len=ncol(A);

j=0; /* j denotes the jth 1 in A;*/

1 1 0 6 1 0 1};

len=ncol(A);

j=0; /* j denotes the jth 1 in A;*/

0; /* j denotes the jth 1 in A;*/

do i=1 to len; /*A dnotes the ith element of A;*/

do i=1 to len; /*A dnotes the ith element of A;*/

if A=1 then do;

j=j+1;

A=j;

end;

end;

print A;

if A=1 then do;

j=j+1;

A=j;

end;

end;

print A;

1;

A=j;

end;

end;

print A;

end;

end;

print A;

end;

print A;

print A;

quit;

;

[此贴子已经被作者于2008-1-7 6:24:41编辑过]

已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 10 精彩帖子

总评分: 经验 + 3  论坛币 + 10   查看全部评分

板凳
yzhouwen 发表于 2008-1-7 06:30:00

proc iml;

/*the following program replace the jth 1 in a vector A by j */

  A={1 1 0 6 1 0 1}; /* an other example*/

   len=ncol(A);

    j=0;            /* j denotes the jth 1 in A;*/

   do i=1 to len;  /*A dnotes the ith element of A;*/

       if A=1 then do;

               j=j+1;

               A=j;

         end;

   end;

print A;

quit;

已有 1 人评分论坛币 收起 理由
bakoll + 10 精彩帖子

总评分: 论坛币 + 10   查看全部评分

报纸
abelus 发表于 2008-1-7 10:14:00
data 中使用retain也能做到,相对简洁一些。

地板
yzhouwen 发表于 2008-1-7 22:05:00

Thanks for the reminder, I modified the code a little bit, looks little better.

data one;

    input x @@;

      cards;

       1 2 1 1 0 0 2 1 1 8

;

 

 data two;

      set one;

       retain j 0;

       do i=1 to _N_;

           if x=1 then do;

               j=j+1;

               x=j;

                end;

       end;

         drop j i;

 run;

proc print noobs; run;

7
l6397 发表于 2008-1-7 22:54:00
yzhouwen

帅哥哟,在线,有人找我吗?    非常谢谢这位高人,感谢您的帮助!!

 下列这些点代表其他数据(后面还有很多数据),我想在编程后输出时,
不输出其他数字,只统计 1 出现的次数和距上次的间隔次数,输出形式
如下:    谢谢!!
下列一组数据: 
 1 . . 1 . . 1 1 . 1 . . . . 1

1、怎样编程,来统计1出现的次数(按竖行输出下列形式) 

 1 . . 2 . . 3 4 . 5 . . . . 6

2、怎样编程,数字1的间隔次数(按竖行输出下列形式) 

 . . 2 . . 2 . . 1 . . . . 4 .

[此贴子已经被作者于2008-1-7 22:57:26编辑过]

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 23:11