LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Oct 2004 15:48:00 -0500
Reply-To:     "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Subject:      Re: Column name
Comments: To: Michael Murff <mjm33@msm1.byu.edu>
Content-Type: text/plain; charset="us-ascii"

Micheal,

While I must admit this design wasn't meant for large datasets, I just created a macro var using a %let statement that was 50000 characters long.

It ate up a lot of memory from the rate at which my computer responded but the technique does not fail from a macro var limitation but rather from a memory limitation. I am running a windows XP with SAS v9.1.2.

Now on to the mainframe, I run SAS v8.2 on os/390. There my limitation is I think some where around 300 lines, how ever much that corresponds to in characters. On the other hand I haven't tried to create a extremely large macro var using a proc SQL into statement that would even come close to testing that limit on big iron. So I do not know if it will let me around the 300 lines issue.

Then there is issue of you could have always designed a %macro that did the same thing in a different way, thereby avoiding the whole space issue if that is a problem.

HTH Toby Dunn

-----Original Message----- From: Michael Murff [mailto:mjm33@msm1.byu.edu] Sent: Wednesday, October 20, 2004 3:28 PM To: SAS-L@LISTSERV.UGA.EDU; Dunn, Toby Subject: Re: Column name

I hesitate to mention a potential constraint on Toby's routine, since I don't presently have a solution to my observation; and admittedly, it's easier to critique a program than write one from scratch. The macro var strategy at issue will work for all but very wide datasets and/or those datasets with very long variable names. A single macro variable can only contain so many characters (or bytes), though I'm not sure what the exact maximum is. And from the looks of my log, there the macro var "rename" is truncated, but something else must be going on because I get the following errors when I try to resolve it in the rename step.

<snip from my log> ERROR: Overflow has occurred; evaluation is terminated. ERROR: Out of memory. <end>

Nevertheless, I have needed a routine of this ilk for some time and it will make a welcome addition to my rather small, but growing tool kit.

Thanks Toby (and Claudia for raising the question),

M.M.

*******************************; %macro mockdata;

%let NCOLS = 10000; %let NOBS = 20; %let SEED = 20041008;

/* mock up market dataset */ data test; do row = 1 to &NOBS; %local i; %do i = 1 %to &NCOLS; co&i._pr = round (10 * ranuni(&seed), 0.0001); %end; output; end; drop row; run;

%mend;

%mockdata;

proc sql noprint; select compress(name||'='||'x'||input(put(varnum,8.),$4.)) into : rename separated by ' ' from sashelp.vcolumn where libname = "WORK" and memname = "TEST"; quit;

%put _user_;

data test2; set test (rename = (&rename)); run; *******************************;

>>> "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US> 10/20/04 7:38 AM >>> Claudia,

The easiest way I can figure is through a SQL into statement hitting your meta data:

Such as this example:

data test; alpha = 1; beta = 1; omega = 1; run;

proc sql noprint; select compress(name||'='||'x'||input(put(varnum,8.),$2.)) into : rename separated by ' ' from sashelp.vcolumn where libname = "WORK" and memname = "TEST"; quit;

data test2; set test (rename = (&rename)); run;

proc contents data = test2; run;

Hth Toby Dunn

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Claudia Sent: Tuesday, October 19, 2004 9:33 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Column name

Hi,

I imported an excel file into SAS. Now I would like to change the column (or array) names so that it's easier for me to compute my models afterwards.

I know that I could either change them directly in excel or again directly in SAS using for instance var1=new_varname, but since I have so many columns (more than 1,000), I don't want to do this by hand.

Is there a way (I guess using a loop) to rename my columns x1, x2, x3, etc... without going one at a time?

Starting at the 4th column, I would like to name my columns x1, x2, ...xn

Sorry for the newbie question,

Claudia


Back to: Top of message | Previous page | Main SAS-L page