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

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

    Yes, there is a putformatted() function. In fact, there are two: putc() and putn(). Putc handles character formats, putn() numeric. Your code will need to look at the format name (all and only character formats start with "$") do determine which to use. Here is the syntax of putc (from the interactive help):

    PUTC(source, format.<,w>)
    

    Arguments

    source 
    is the SAS expression to which you want to apply the format.
    
    format. 
    is an expression that contains the character format you want to apply to source.
    
    w 
    specifies a width to apply to the format. 
    
    Interaction: If you specify a width here, it overrides any width specification
    in the format. 
    

提交回复
热议问题