```Date: Tue, 28 Aug 2007 12:28:39 -0400 Reply-To: "Howard Schreier " Sender: "SAS(r) Discussion" From: "Howard Schreier " Subject: Re: Concatenate variable names from three datasets Content-Type: text/plain; charset=ISO-8859-1 On Mon, 27 Aug 2007 15:42:27 +0200, Lindberg, Andreas wrote: >I have three datasets, each with a single row and 42 columns named F1-F42. Let's call them set one, two and three. I want to create a new empty dataset with 42 columns where the column names are the concatenated values (text) of the same column in each of the three datasets. So the first column in the new dataset would be called "ValueOfF1inSet1ValueOfF1inSet2ValueOfF1inSet3" and the second column would be called "ValueOfF2inSet1ValueOfF2inSet2ValueOfF2inSet3" and so on up to column 42. Any Ideas? > > > V�nliga h�lsningar/Best Regards > > Andreas Lindberg This is an unusual way to keep metadata. It would be easier if you had three columns and 42 rows. Here is one way to work with the given structure. First load test data (4 columns instead of 42): data one two three; input (f1-f4)(:\$10.); if _n_ = 1 then output one ; if _n_ = 2 then output two ; if _n_ = 3 then output three; cards; John Paul George Ringo Goodnight Sall Helwig Barr Larry Moe Curly Shemp ; Now loop to build the new list of names and then create the new data set via CAL EXECUTE: data _null_; length all \$ 100; _1 = 1; do i = 1 to 4; set one point=_1; array _name(4) \$ f1-f4; all = catx(' ',all, _name(i) ); set two point=_1; all = cats( all, _name(i) ); set three point=_1; all = cats( all, _name(i) ); end; call execute('data new; retain ' || trim(all) ||' 0; stop; run;'); stop; run; See what you have: proc contents data=new; run; Excerpts from PROC CONTENTS output: Data Set Name WORK.NEW Observations 0 Alphabetic List of Variables and Attributes # Variable Type Len 3 GeorgeHelwigCurly Num 8 1 JohnGoodnightLarry Num 8 2 PaulSallMoe Num 8 4 RingoBarrShemp Num 8 ```

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