全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2265 3
2014-11-18
悬赏 80 个论坛币 已解决
复制代码
求助input问题,输入有点free style,不过变量都是按照|这个符号来分隔的;
最终还是被input击败了,救助,谢谢:)

最佳答案

pobel 查看完整内容

data attrib; length str $4000; infile datalines dlm = '|' _infile_=tmp ; do while (count(str,"|")
二维码

扫码加我 拉你入群

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

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

全部回复
2014-11-18 11:37:57
data attrib;
  length str  $4000;
  infile datalines dlm = '|' _infile_=tmp ;
  do while (count(str,"|")<3);
    input ;
        str=cats(str,tmp);
  end;

  pgm=scan(str,1,"|");
  title=scan(str,2,"|");
  footnote=scan(str,3,"|");
  input point;

  drop str;
datalines4;
t_1|
title1 "title1 for &pgm.";|
footnote1 "footnote1 for t_1";
footnote2 "footnote2 for t_1";|
6.3|
t_2|
title1 "title1 for &pgm.";
title2 "title2 for &pgm.";|
footnote1 "footnote1 for t_2";
footnote2 "footnote2 for t_2";
footnote3 "footnote3 for t_2";|
5.2
;;;;
run;
二维码

扫码加我 拉你入群

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

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

2014-11-18 17:37:31
竖线是个累赘,try this


data attrib (where= (point>0) drop=temp);
length temp footnote title $500 pgm $8;
retain footnote ''  title '' pgm '';
infile datalines ;
input temp  &  $500. ;

if find(temp,'title')>0 then title= strip(title)|| tranwrd(temp,'|','');
else if  find(temp,'footnote')>0 then footnote= strip(footnote)|| tranwrd(temp,'|','');
else if anyalpha(tranwrd(temp,'|',''))=0 then point= input(tranwrd(temp,'|',''),best.) ;
else pgm = tranwrd(temp,'|','');
output;
  if point>0  then call missing(title,footnote, pgm);
datalines4;
t_1|
title1 "title1 for &pgm.";|
footnote1 "footnote1 for t_1";
footnote2 "footnote2 for t_1";|
6.3|
t_2|
title1 "title1 for &pgm.";
title2 "title2 for &pgm.";|
footnote1 "footnote1 for t_2";
footnote2 "footnote2 for t_2";
footnote3 "footnote3 for t_2";|
5.2
;;;;

run;
二维码

扫码加我 拉你入群

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

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

2014-11-19 11:28:08
You can do it sa simple as below.   

data _null_;
      infile 'c:\temp\attrib.txt';
          file 'c:\temp\attrib.mod' ls =32767;
      input;
          if length(_infile_)>1 then put _infile_ @;  
    run;

        data attrib;
        length pgm $10 title $200 footnote $400 point 8;
        infile 'c:\temp\attrib.mod' delimiter='|' ls =32767;
        input pgm title  footnote  point @@;
        run;

        proc print;run;
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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