need to change the units

New Contributor
Posts: 3

need to change the units

I use SAS 9.4 version.


One column has different units (cm, ft, etc), and I need to change them to one unit (m).

I separated them first, then I changed them mathematically identical to meter. 

But, how can I merge those columns into one column(meter) again?


Thank you.

Super User
Posts: 8,219

Re: need to change the units

Posted in reply to oenomel1992

I would have used if-then-else statements to only create the one desired column. However, since you created different columns, if all but the desired column have missing values, you could use the COALESCE function (see: )


Art, CEO,


Super User
Super User
Posts: 9,855

Re: need to change the units

Posted in reply to oenomel1992

I would suggest to follow a set of rules we have in my industry formed by the CDISC organisation.  Have 4 columns;

Results in original units

Original units

Results in standard units

Standard units


To apply these rules it depends on how you are setup and how many there are.  If there is one or two and you don't already have them in a dataset then:

data want;
  set have;
    when('cm') standard_results=results/100;

If there are lots, then its a good idea to put these in a dataset, so something like:


cm                m                     / 100



Then you can just merge this on and action the formula programatically.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation