楼主: hxmlcy
1734 10

[问答] 求教 [推广有奖]

  • 0关注
  • 0粉丝

硕士生

7%

还不是VIP/贵宾

-

威望
0
论坛币
485 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
32620 点
帖子
29
精华
0
在线时间
219 小时
注册时间
2012-10-20
最后登录
2017-10-10

楼主
hxmlcy 发表于 2013-3-28 21:37:23 |AI写论文
50论坛币

数据集a:

a

b

c

0

0

境外法人股
国有

0

0

0

境内法人股

0

国有

0

0

0

境内法人股

0

国有

0

0

0

境内法人股

0

0

境内法人股

0

0

境内法人股

0

希望得到:
d

境外法人股

国有

境内法人股

国有

境内法人股

国有

境内法人股
境内法人股
境内法人股
即将abc变量取不为0的数据,赋到d变量中,不用sql,先谢谢了

最佳答案

yongyitian 查看完整内容

/* this is a good example using array, do-loop and if-then */ data test; input A $ B $ C $; datalines; 0 0 JingWai GuoYou 0 0 0 JingWai 0 GuoYou 0 0 0 JingWai 0 ; run; /* this is a standard example of array and do-loop */ data want1; set test; array myarray{3} a b c; do i = 1 to dim(myarray); if myarray(i) ^="0" then d = myarray(i); end; drop i; run; /* T ...
关键词:法人股 ABC 数据集 sql 法人股

沙发
yongyitian 发表于 2013-3-28 21:37:24
/* this is a good example using array, do-loop and if-then */

data test;
input A $ B $ C $;
datalines;
0 0 JingWai
GuoYou 0 0
0 JingWai 0
GuoYou 0 0
0 JingWai 0
;
run;

/* this is a standard example of array and do-loop */
data want1;  
    set test;
        array myarray{3} a b c;
        do i = 1 to dim(myarray);
       if myarray(i) ^="0" then d = myarray(i);
        end;
        drop i;
run;

/* This is an example of using do-OVER loop with array and if-then */
data want2;   
   set test;
   array Use_Over a b c;   
   do over Use_Over;
   if Use_Over ^="0" then d2 = Use_Over;
   end;
run;


proc print data=want1; run;
proc print data=want2; run;

藤椅
Imasasor 发表于 2013-3-28 21:40:12
that is a very basic question
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

板凳
hxmlcy 发表于 2013-3-28 21:53:36
Imasasor 发表于 2013-3-28 21:40
that is a very basic question
我是sas小白,望指点,不胜感激

报纸
Imasasor 发表于 2013-3-28 22:33:13
我不想说
欢迎加入亚太地区第一R&Python数据挖掘群: 251548215;

地板
hxmlcy 发表于 2013-3-28 22:45:26
Imasasor 发表于 2013-3-28 22:33
我不想说
好吧,不勉强

7
farmman60 发表于 2013-3-29 01:08:56
data have;
input a $ b$ c$;
cards;
ab 0 0
0 cd 0
0 dd 0
aa 0 0
0  0 bd
;
run;


data want;
set have;
new=left(compress(catx(' ', of a,b,c),'0'));
run;
proc print;
run;

8
hxmlcy 发表于 2013-3-29 12:49:08
yongyitian 发表于 2013-3-29 00:18
/* this is a good example using array, do-loop and if-then */

data test;
谢谢你的热心帮助,非常感激

9
hxmlcy 发表于 2013-3-29 12:50:06
farmman60 发表于 2013-3-29 01:08
data have;
input a $ b$ c$;
cards;
谢谢你的热心回复,非常感激

10
a6566792 在职认证  发表于 2013-3-29 13:46:05
Imasasor 发表于 2013-3-28 22:33
我不想说
你这人这样说有点过了,人可以直,但也要尊重别人,有没听过莫欺少年穷
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Imasasor + 80 + 80 + 2 + 2 + 3 分析的有道理

总评分: 经验 + 80  论坛币 + 80  学术水平 + 2  热心指数 + 2  信用等级 + 3   查看全部评分

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 01:28