| 
 | 
沙发
 
 
 楼主 |
发表于 2012-4-15 12:32:18
|
只看该作者
 
 
 
Re: 请教一个字符型变量的问题
[code:1m5rsf9s]data raw; 
    input oldid :$20. glu; 
datalines; 
10181800058-2 7.46 
10181800059-0 5.98 
10181800059-2 7.9 
10181800060-0 5.15 
10181800060-2 5.29 
10181800061-0 8.89 
10181800061-2 20.34 
10181800062-0 5.47 
10181800062-2 8.49 
10181800063-0 5 
10181800063-2 6.42 
10181800064-0 5.83 
10181800064-2 11.01 
10181800065-0 5.7 
10181800065-2 4.89 
10181800066-0 5.4 
; 
data _null_; 
    length id $20; 
    if _n_=1 then do; 
        declare hash h(hashexp:8,ordered:'a'); 
        rc=h.defineKey('id'); 
        rc=h.defineData('id','glu1','glu2'); 
        rc=h.defineDone(); 
        call missing(id,glu1,glu2); 
    end; 
    set raw end=last; 
    id=cats('10',substr(oldid,5,7));  
    rc=h.find(); 
    select(scan(oldid,-1,'-')); 
        when('0') glu1=coalesce(glu,glu1); 
        when('2') glu2=coalesce(glu,glu2); 
        otherwise; 
    end; 
    if rc then rc=h.add(); 
    else rc=h.replace(); 
    if last then rc=h.output(dataset:'out'); 
run;[/code:1m5rsf9s] |   
 
 
 
 |