|
First of all, you don't need a macro, haven't you been reading SAS-L lately? ;-)
data b ( drop = j );
set a;
format k1-k2 $2.;
array new k1 - k2; /* single dash is fine / safer for your application */
array old x1 - x4;
do j=1 to 2;
new(j)=compress(old((j-1)*2+1)||old((j-1)*2+2));
end;
run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of df
ss
Sent: Monday, May 16, 2005 4:02 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: array question
Hello SAS-L,
I have a data set like that
x1 x2 x3 x4
1 2 3 4
5 6 7 8
I would like to combind them into two new variables k1
and k2.
K1=compress(x1||x2);
K2=compress(x3||x4);
the final data set should be like that
x1 x2 x3 x4 k1 k2
1 2 3 4 12 34
5 6 7 8 56 78
I want to write a macro to do that
data b;
set a;
format k1-k2 $2.;
array new k1 -- k2;
array old x1 -- x4;
do j=1 to 2;
do i=1 to 4;
new(j)=compress(old(i)||old(i+1));
end;
end;
run;
But the result is not right, they only combind the x3
and x4 into k1 and k2.
I want to know the reason for that.
Thank you for your help
HHH
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
__________________________________________________________________________________________________________________________________
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.
|