BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

12 REPLIES 12
Hima
Obsidian | Level 7

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;

tmm
Fluorite | Level 6 tmm
Fluorite | Level 6

Hum. That did not work. It is still named TIN

Reeza
Super User

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;

Haikuo
Onyx | Level 15

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

art297
Opal | Level 21

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.

Haikuo
Onyx | Level 15

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

art297
Opal | Level 21

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.

Haikuo
Onyx | Level 15

Thanks, Art! And Howard! This is so COOL!

Reeza
Super User

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;

art297
Opal | Level 21

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;

Reeza
Super User

That makes way more sense! ThanksSmiley Happy

Linlin
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 3010 views
  • 0 likes
  • 6 in conversation