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 (June 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 11 Jun 1999 10:00:23 -0400
Reply-To:   Karen Kinsey <KKinsey@PREVISIONMARKETING.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Karen Kinsey <KKinsey@PREVISIONMARKETING.COM>
Subject:   Transposing a dataset
Content-Type:   text/plain

I sent this message yesterday but from the responses I've received so far I guess I wasn't clear enough as to what I wanted at the end. I've included in this message an example of the output dataset that I'd like at the end.

I have a dataset that I need to transpose. Here is an example of what needs to be transposed.

data mailaud; input custid $1. tovid $8. audcode $10.; cards; 1 mail0299 primary 1 mail0699 secondary 1 mail0799 primary 2 mail0499 none 3 mail0799 primary 4 mail0898 secondary 4 mail297 secondary ; run;

There are specific requirements around the code however. I cannot hard code the variable names because the list of tovids keeps being updated.

I need an id level dataset where the variables are mail+#### (#### referring to the numbers at the end of mail for the tovid), aud+####, and custid.

So for example, for the tovid = mail0299, the new variable names would be mail0299, and aud0299 with values equal to 0 or 1, and the audcode respectively. I have tried doing this multiple ways and am at a loss as to how to continue. I tried doing this in a data step with macro variables being reassigned, but I get stuck when trying to use call symput since I have to update it in a separate data step. Any suggestions?

Here is what I'd like as output:

<<...>>

I'm including my last ditch code even though I know it's wrong to give you an idea of where I was headed. If it is hopelessly wrong please let me know. I'm definitely still learning the SAS programming ropes!

DATA MAILHIST; SET MAILHIST.HISTORY END = EOF; BY CUSTID; RETAIN; %MACRO DAT; %DO %UNTIL(_N_ = EOF); IF INDEX(tovid,'MAIL') THEN DO; TOV = SUBSTR(TOVID,5,3); CALL SYMPUT('X',TOV); MAIL&X = 1; LENGTH AUD&X $10; AUD&X = AUDCODE; END; %END; %MEND DAT; %DAT IF LAST.CUSTID THEN DO; ARRAY MISN[*] _NUMERIC_; DO I = 1 TO DIM(MISN); IF MISN[I] = . THEN MISN[I] = 0; OUTPUT; END; END; RUN;

Thanks!

Karen Kinsey Prevision Marketing 55 Old Bedford Road Lincoln, MA 01773 (781) 259-5142


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