How can I make a character variable equal to the formatted value of a numeric variable for arbitrary SAS formats?

前端 未结 5 568
不知归路
不知归路 2021-02-08 19:57

If I have a numeric variable with a format, is there a way to get the formatted value as a character variable?

e.g. I would like to write something like the following to

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 20:18

    I can do this with macro code and sashelp.vcolumn but it's a bit fiddly.

    proc sql noprint;
      select trim(left(format)) into :format
        from sashelp.vcolumn
        where libname eq 'WORK' and memname eq 'TEST';
    run;
    
    data test2;
      set test;
      i_formatted = put(i, &format);
      put i_formatted;
    run;
    

提交回复
热议问题