作者smartqq (蓉)
站内Statistics
标题[程式] sas 大小写问题
时间Fri Mar 25 01:55:48 2011
[软体程式类别]:
请填入软体程式类别 例如SAS、SPSS、R、EVIEWS...等
sas
[程式问题]:
资料处理、回归、叙述统计、logistic、probit...等
资料处理
[软体熟悉度]:
请把以下不需要的部份删除
新手(不到1个月)
[问题叙述]:
我在用merge要并资料的时候 发现有大小写区分的问题
请问要怎麽样把我sas档案里面的内容小写改成大写呢?(大小写转换)
或是当sas在合并资料的时候,有没有指令可以叫它" W "和" w "视为同一个呢?
我有查了一下google 大多数都说是写程式的code不用区分大小写 但是还是无解
感谢各位!!!
[程式范例]:
我现在主要目的是要并公司名称 资料呈现的方式如下
first5是指该间公司第一个字的前五个字母,second5指第二个字的前五个字母
档案cust
cname first5 second5
Wal-mart Store Inc. Wal-m Store
WAL-MART STORE INC. WAL-M STORE
wal-mart store wal-m store
档案fight
CONML first5 second5 conm comnam
Wal-mart Store Inc. Wal-m Store WAL-MART STORE INC. wal-mart store
最後跑出来的结果是
cname first5 second5 CONML conm comnam
Wal-mart Store Inc. Wal-m Store Wal-mart Store Inc. WAL-MART wal-mart
WAL-MART STORE INC. WAL-M STORE
wal-mart store wal-m store
就是下面这二个(大小写不同)不会对到
程式码如下:
data customer.fight; set customer.fight;
first5=substr(scan(CONML,1,' '),1,5);
second5=substr(scan(CONML,2,' '),1,5);run;
data customer.cust; set customer.cust;
first5=substr(scan(Cname,1,' '),1,5);
second5=substr(scan(Cname,2,' '),1,5);
Proc sort data=customer.fight ; by FIRST5 second5;
Proc sort data=customer.cust; by FIRST5 second5;
data customer.profs5merge;
merge customer.cust customer.fight;by first5 second5;run;
-----------------------------------------------------------------------------
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 115.80.146.164
1F:推 west1996:upcase()小写转大写 lowcase()大写转小写 03/25 02:39
2F:→ west1996:写程式大小写不分的意思是只写程式码时大小写没差,资料 03/25 02:42
3F:→ west1996:里的大小写就一定会有差了 03/25 02:42
4F:推 wlsherica:用function罗! 即楼上w大提到的function 03/25 10:47