From: Bill McKirgan on 23 Dec 2009 13:12 On Dec 23, 11:50 am, shakespeare_1...(a)HOTMAIL.COM (William Shakespeare) wrote: > Say I have a data set with 3 variables, all numeric. I need to convert > the second to character and maintain the original order of the variables. > I can do this, but with two data steps, on to convert the variable in > question and drop the old variable, and another to reorder the variables. > Is there a way to do this in one step? William, As far as I know this takes two datasteps. --Bill
From: Arthur Tabachneck on 23 Dec 2009 13:11 Couldn't you use something like:? data want (drop=two_num); retain one two three; set have (rename=(two=two_num)); two=put(two_num,3.); run; HTH, Art ------- On Wed, 23 Dec 2009 12:50:13 -0500, William Shakespeare <shakespeare_1040(a)HOTMAIL.COM> wrote: >Say I have a data set with 3 variables, all numeric. I need to convert >the second to character and maintain the original order of the variables. >I can do this, but with two data steps, on to convert the variable in >question and drop the old variable, and another to reorder the variables. >Is there a way to do this in one step?
From: "Keintz, H. Mark" on 29 Dec 2009 00:17 On Dec 23, 11:50 am, shakespeare_1...(a)HOTMAIL.COM (William Shakespeare) wrote: > Say I have a data set with 3 variables, all numeric. I need to convert > the second to character and maintain the original order of the variables. > I can do this, but with two data steps, on to convert the variable in > question and drop the old variable, and another to reorder the variables. > Is there a way to do this in one step? > William, William: The discussion earlier about placing new variables into location interior to the list of old variables led to this one-step solution: data have; input x y z; datalines; 11 12 13 21 22 23 run; data need; if 0 then set have (keep=x); length new_y $2; set have ; new_y=put(y,2.); drop y; run; Regards, Mark
|
Pages: 1 Prev: data step rename Next: How to run a procedure multiple times? |