|Date: ||Wed, 6 Feb 2008 23:48:20 +0000|
|Reply-To: ||toby dunn <tobydunn@HOTMAIL.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||toby dunn <tobydunn@HOTMAIL.COM>|
|Subject: ||Re: rename a column with a macro variable|
|Content-Type: ||text/plain; charset="iso-8859-1"|
Yes it should and if you post an example starting data set andwhat you expect the ending data set to look like I bet we can get you from point A to point B with a cleaner solution.
"Don't bail. The best gold is at the bottom of barrels of crap."
"Be prepared. Luck is where preparation meets opportunity."
> Date: Wed, 6 Feb 2008 15:06:49 -0800
> From: diaphanosoma@GMAIL.COM
> Subject: rename a column with a macro variable
> To: SAS-L@LISTSERV.UGA.EDU
> I'm trying to rename a column in a data set with a macro variable
> name. Should be easy, but I can't do it.
> Here is the pertinent code:
> /*Load unique causes of death into death_names*/
> proc sql;
> select distinct quote(trim(death_cause))
> into :death_names separated by '+'
> from coc.codes ;
> /* loop through for each distinct death name */
> %do i= 1 %to &sqlobs.;
> DATA NEW&i; SET coc.death;
> where coc=&geog and icd10_description= %scan(&death_names.,&i,'+');
> /*works nicely */
> lots more code......
> /*I want to make the last data set anemable to merging all the work
> data sets together
> so I transpose the data and sort */
> proc transpose data=new4&i out =t&i ;
> proc sort data=t&i ; by _name_;
> /* Next I want to to rename the automatic variable "col1", which
> contains the data, to
> the variable name stored in the macro. I can't seem to do it.
> The names of the variable are something like "cancer of bladder &
> urinary tract" or "cancer of colon", these can't be variable names
> becuase they are more than one word long. Also note the "&" that
> needs to be dealt with. I'm trying to compress the blanks. Ideally I
> would like to subsitute the blanks for underscores e.g.
> I'm trying:
> data t&i; set t&i (rename =col1 =
> /*lots of errors but after playing with it a bit (qstrn, qcmpres,
> etc)I can get a variable name of " " " (a quotation mark)
> How can I get the rename to work here?
Need to know the score, the latest news, or you need your HotmailŪ-get your "fix".