As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Using the SASMSG function for table lookup

From sasCommunity
Jump to: navigation, search

Did you know that the SASMSG function can be used to retrieve keyed text values? You first load your key-value pairs in a SAS message dataset -- which is a plain old dataset with some specific variables, sorted and indexed in a specific way. Once the data are ready, then it is just like having a hash table you can lookup from anywhere, even in the open!

proc sql;
    create table heights as 
    select "en_US" as locale length=5, trimn(upcase(name)) as 'KEY'n length=60, 
       1 as lineno length=5, strip(putn(height, "best8.")) as text length=1200 
    from sashelp.class  order by locale, 'KEY'n, lineno desc;
 
    create index indx on heights(locale, key);
quit;
 
options locale="en_US"; /* required */
 
%put Alfred:***%sysfunc(sasmsg(heights, ALFRED, noquote))***;
%put Alice :***%sysfunc(sasmsg(heights, ALICE, noquote))***;
%*-- on log
Alfred:***69***
Alice :***56.5***
--*;
Submitted By chang_y_chung