楼主: hengda
2163 5

请问如何读入数据 [推广有奖]

  • 0关注
  • 0粉丝

大专生

88%

还不是VIP/贵宾

-

威望
0
论坛币
431 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2374 点
帖子
14
精华
0
在线时间
115 小时
注册时间
2009-3-27
最后登录
2010-8-24

楼主
hengda 发表于 2010-1-29 21:50:45 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
例如我现在有一些数据想读入data
1232&12
dasf&
fdas1&asdf1&
我想读入的效果是按&分行
结果如下:
1232&
12dasf&
fdas1&
asdf1&
如何用sas读入?谢谢
二维码

扫码加我 拉你入群

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

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

关键词:读入数据 Data Das FDA SDF 数据

回帖推荐

bobguy 发表于2楼  查看完整内容

Hope this helps. data t1; retain y ' '; infile cards; input; n=length(_infile_) - length(compress(_infile_,'&')); do i = 1 to n; x=catt(y,scan(_infile_,i,'&'),'&'); output; end; y=scan(_infile_,n+1,'&'); drop y n i; cards; 1232&12 dasf& fdas1&asdf1& ; proc print; run;

本帖被以下文库推荐

沙发
bobguy 发表于 2010-1-29 23:54:14
hengda 发表于 2010-1-29 21:50
例如我现在有一些数据想读入data
1232&12
dasf&
fdas1&asdf1&
我想读入的效果是按&分行
结果如下:
1232&
12dasf&
fdas1&
asdf1&
如何用sas读入?谢谢
Hope this helps.

data t1;
retain y ' ';
infile cards;
input;
n=length(_infile_) - length(compress(_infile_,
'&'));
do i = 1 to n;
x=catt(y,scan(_infile_,i,
'&'),'&');
output;
end;
y=scan(_infile_,n+
1,'&');
drop y n i;
cards;
1232&12
dasf&
fdas1&asdf1&
;
proc print; run;
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

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

藤椅
hengda 发表于 2010-1-30 13:08:00
谢谢,貌似第一行最后的2没读到;另外有没有不使用do end的循环而直接读入的?

板凳
xiaosanmao 发表于 2010-1-30 14:47:52
抄袭一下
data t1;
retain y ;
infile cards;
input;
n=length(_infile_) - length(compress(_infile_,'&'));
do i = 1 to n;
x=compress(catt(y,scan(_infile_,i,'&'),'&'),.);
output;
end;
y=scan(_infile_,n+1,'&');
cards;
1232&12
dasf&
fdas1&asdf1&
;
proc print; run;

报纸
bobguy 发表于 2010-1-30 22:44:38
xiaosanmao 发表于 2010-1-30 14:47
抄袭一下
data t1;
retain y ;
infile cards;
input;
n=length(_infile_) - length(compress(_infile_,'&'));
do i = 1 to n;
x=compress(catt(y,scan(_infile_,i,'&'),'&'),.);
output;
end;
y=scan(_infile_,n+1,'&');
cards;
1232&12
dasf&
fdas1&asdf1&
;
proc print; run;
Change
retain y ;   -----> retain y ' ';

There is an important point here.

地板
xiaosanmao 发表于 2010-1-30 23:07:14
bobguy 发表于 2010-1-30 22:44
xiaosanmao 发表于 2010-1-30 14:47
抄袭一下
data t1;
retain y ;
infile cards;
input;
n=length(_infile_) - length(compress(_infile_,'&'));
do i = 1 to n;
x=compress(catt(y,scan(_infile_,i,'&'),'&'),.);
output;
end;
y=scan(_infile_,n+1,'&');
cards;
1232&12
dasf&
fdas1&asdf1&
;
proc print; run;
Change
retain y ;   -----> retain y ' ';

There is an important point here.
But if you change like that,you can't get the right answer.

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

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