I am reading in variables from a few different datasets using proc sql, which I am trying to improve on.
What I'd like to do is read in a variable from a dataset using proc sql, but take the log of the variable as it's read in, but keep the variable name.
PROC SQL;
CREATE TABLE all AS
SELECT DISTINCT a.*,
b.var1, LOG(b.var2) AS log_var2
FROM pop AS a
INNER JOIN trt AS b
ON a.study=b.study AND a.subj=b.subj
;
QUIT;
The above creates a table with the variable log_var2, but it does not have the variable name from var2. Is there a way to keep this? The idea is that the label is used later on when transposing and the label is used as values within a table, but var2 itself may change so I need a robust method of labelling log_var2 with the label name from var2.
Any ideas?
Thanks in advance
variable label
from var2. The variable label is what it looks like by default when you open the dataset, but can be different from thevariable name
, which is what you use to refer to it in a program. – Joe