01-18-2018 09:52 AM
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?
01-18-2018 10:01 AM
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: http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p1vjttz6nua... )
Art, CEO, AnalystFinder.com
01-18-2018 10:31 AM
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
Results in 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; select(original_units); when('cm') standard_results=results/100; ... end; standard_units="m"; run;
If there are lots, then its a good idea to put these in a dataset, so something like:
ORIG_UNIT STAND_UNIT COMPUTATION
cm m / 100
Then you can just merge this on and action the formula programatically.