| 
 | 
地板
 
 
 楼主 |
发表于 2013-7-15 16:51:02
|
只看该作者
 
 
 
Re: 请教:SAS数据处理
[code:2xish7a9]proc sql noprint; 
    select distinct value into :varlist separated by ' '  
        from raw where upcase(value) ne 'STOP' order by value; 
quit; 
data out(drop=char regular x y); 
    do until(last.id); 
        set raw; 
        by id; 
        length cum $100; 
        retain cum; 
        array var &varlist; 
        if upcase(value) ne 'STOP' then cum=catx(' ',cum,value); 
        else do; 
            do over var; 
                char=vname(var); 
                regular=prxparse(cats('s/(\b',char,'\b)+/',char,'/')); 
                call prxchange(regular,-1,strip(cum),cum,x,y,var); 
                cum=prxchange(cats('s/(\b',char,'\b\s?)+/',char,'->/'),-1,cum); 
            end; 
            cum=prxchange(cats('s/->$//'),1,strip(cum)); 
            output; 
            call missing(cum); 
        end; 
    end; 
run;[/code:2xish7a9] |   
 
 
 
 |