i want grab number of variable levels variable output of unique identifiers method not work. want use unique id's , associate numbers 1-num_levels proc freq.
here have proc freq:
proc freq data=my_data (keep=ids) nlevels; table all/out=out_data; %let dim=levels; %let ids; run;
then tried use macro variables didn't work including manual version of proc format give idea of trying achieve trying make more automated.
proc format; invalue index "1234" = 1 "2345" = 2 . . . "8901" =25; /*25 represents output of levels variable proc freq couldn't figure out how grab either*/ run;
any appreciated. thank you!
here's worked solution, illustrates proc format cntlin way of doing this. idea here mask names observation number instead.
*create list of unique names; proc freq data=sashelp.class noprint; table name/out = mask; run; *create control data set. variables need set are: fmtname, start, label , type; data name_fmt; set mask; fmtname = 'namefmt'; type='j'; *j specified character informat, c character format; start=name; label = put(_n_, z2.); *use row number recoded value; run; *create format; proc format cntlin=name_fmt; run; *sample usage; data class; set sashelp.class; name_masked = input(name, $namefmt.); drop name; run;
Comments
Post a Comment