SAS-- handling character variables

    

sasuser.agency99 Data;
     SET sasuser.talent; 
    length State $ 10 ; 
    State = Scan (address2, 2 , ' , ' ); * extracted from the list after the second comma dividing element, the third parameter can not write, good plurality of default special symbol; 
RUN;                             / * attached to a plurality of delimiters is designated as a * / 
proc Print Data = sasuser.agency99; 
RUN; 

Data sasuser.newtal; 
    SET sasuser.talent; 
    Sex = substr (ID, . 4 , 1 ); id * extraction of variables . 4 characters after the start, before a character; 
RUN; 
proc Print Data =sasuser.newtal; 
RUN; 

Data sasuser.datalent; 
    SET sasuser.njtalent; 
    substr (newphone, 2 , . 3 ) = 302 ; 
RUN; 
proc Print Data = sasuser.datalent; 
RUN; 

/ * TRIM remove excess because the format of the problems caused by space 
 A = TRIM (B) || C   * / 


Data sasuser.stage; 
    SET sasuser.talent;
     iF index (Comment, ' Stage ' )> 0 ;    / * search for the variable has a specified string, comprising the> 0 * / 
RUN;                                 / * Note that index is not SEMICOLON * /
Print Data proc = sasuser.stage; 
RUN; 

/ * A = the upcase (B); 
  B = loecase (A); * / 

/ * Modify the specific character string 
country = tranwrd (country, 'burma ', 'myanmar'); the Myanmar burma changed * / 

/ * taking the integer part of 
A = int (B); * / 

/ * reserved decimal places 
a = round (b, .2) ; two decimals, default to one decimal * /

 

Guess you like

Origin www.cnblogs.com/super-yb/p/11830107.html
Recommended