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

前端 未结 5 572
不知归路
不知归路 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:41

    Use vformat() function.

    /* test data */
    data test;
      i = "10jun2009"d;
      format i ddmmyy10.;
    run;
    
    /* print out the value using the associated format */
    data _null_;
      set test;
      i_formatted = putn(i, vformat(i));
      put i_formatted=;
    run;
    /* on log
    i_formatted=10/06/2099
    */
    

提交回复
热议问题