data chi (drop = no yes rename=tin=who);
set tax;
array _col(2) no yes;
do _n_=1 to 2;
admission = vname (_col(_n_));
count = _col(_n_);
output;
end;
run;
It does not change my column named tin to name it who instead. everything else works great.
You might still see the name 'tin' because the label assigned to the variable 'who' is 'tin'.
try the following with all labels removed. Or just right click the variable and check the properties.
data chi (drop = yes no RENAME=(TIN=WHO));
set tax;
attrib _all_ label='';
array _col(2) no yes;
do _n_=1 to 2;
admission = vname (_col(_n_));
count = _col(_n_);
output;
end;
run;
data chi (drop = yes no RENAME=(TIN=WHO));
set tax;
array _col(2) no yes;
do _n_=1 to 2;
admission = vname (_col(_n_));
count = _col(_n_);
output;
end;
run;
Hum. That did not work. It is still named TIN
You might still see the name 'tin' because the label assigned to the variable 'who' is 'tin'.
try the following with all labels removed. Or just right click the variable and check the properties.
data chi (drop = yes no RENAME=(TIN=WHO));
set tax;
attrib _all_ label='';
array _col(2) no yes;
do _n_=1 to 2;
admission = vname (_col(_n_));
count = _col(_n_);
output;
end;
run;
When you just have one variable to rename, parenthesis is not must to have, your original code should work.
My guess is that the variable name has already been changed, however, the label is still 'tin'. When you open in explorer, it still shows the original label name. Find out the answer by double click the variable name or use proc print, proc contents.
Regards,
Haikuo
Haikuo: A second thing I learned this week! And it is only Wednesday! I'm still going to use parentheses in my own recode statements, as I know it will ALWAYS work regardless of the number of variables being recoded, but I never knew that you didn't need them for just one recode.
Art, if I have to count how many SAS stuff that I have learned directly from you, I would need a counter that at least supports 3 digits. :smileysilly:. BTW, what was the first thing if you don't mind sharing?
Haikuo
Haikuo: Howard's use of imbedding _numeric_ and _character_ in variable lists. e.g.:
proc print data=sashelp.class;
var name-numeric-weight;
run;
Hey, I've been trying to learn this language for 38 years now and, almost every week, still learn something I didn't know.
Thanks, Art! And Howard! This is so COOL!
Am I missing something or do the following produce the exact same output?
What was the first one supposed to do?
proc print data=sashelp.class;
var name-numeric-weight;
run;
proc print data=sashelp.class;
var _numeric_;
run;
Fareeza, My fault! I unsuccessfully tried to copy and paste from a previous post. Try the following:
proc print data=sashelp.class;
var name _numeric_;
run;
proc print data=sashelp.class;
var _numeric_;
run;
That makes way more sense! Thanks
Hi Art,
I thought you wanted to show how to print all numeric or character variables between two variables. In the example below, the two outputs are different. Thanks -Linlin
data class;
set sashelp.class;
age2=age;
w2=weight;
proc print data=class;
title print out all numeric variables;
var _numeric_;
run;
proc print data=class;
title print out all numeric variables between name and weight;
var name-numeric-weight;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.