04-06-2012 10:45 AM
I have a table that is as follows:
mem admit readmit sevcd sevdesc
1111 1 0 1 minor
2222 1 1 1 minor
3333 1 0 2 moderate
4444 1 1 2 moderate
I want to rename mem to who as well as replace all those numbers with the word National. I want to keep all the other columns as they are. I tried this but it does not work right
data ntl (keep = admit readmit sevcd sevdesc);
who = vname(national);
label = mem(who);
04-06-2012 10:57 AM
Syntax for renaming a variable is:
Rename oldvariablename = newvariablename
So it looks like you want RENAME MEM=WHO;
Your KEEP = variable list won't keep the new variable WHO though.
If you want all values of WHO to be "National" though it would be simpler to use:
and add WHO to the keep list.
04-06-2012 11:14 AM
and the output needs to now look like this
who admit readmit sevcd sevdesc
national 1 0 1 minor
national 1 1 1 minor
national 1 0 2 moderate
national 1 1 2 moderate
04-06-2012 11:25 AM
What do you mean the "Output" needs to look like this?
If you are worried about the order of columns in a dataset then:
data ntl (keep=who admit readmit sevcd sevdesc);
Personally, I don't worry about the column order in the data and work with what ever report procedure I'm using to control output order.
04-06-2012 12:04 PM
The original code contained an END; statement...that is why it is asking for a DO statement
You can use a LENGTH statement prior to the SET statement, to order your columns. Of course, PROC SQL works for this also, since you SELECT the variables and the order you want them to appear.
However, your REPORT/PRINT procedures will allow you to display the variables in any order.