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 (January 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 27 Jan 2010 09:28:31 -0800
Reply-To:     xlr82sas <xlr82sas@AOL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject:      Re: SASware ballot #18 Proc Transpose preserving variable
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

HI,

For some transposes you may be able to use this sleezy cheesy trick. I store code in the label.

You can automate this with datastep function vtype, vlabel or macros below. For a complete set of attribute macros see utl_tipweb.txt at

http://homepage.mac.com/magdelina/.Public/utl.html

Macro below

data bignum; label big ="input(big,hex16.)"; label name ="name"; set sashelp.class(keep=name); big=put(constant('BIG'),hex16.); output; stop; run;

proc transpose data=bignum out=bigxpo; var name big; run;

proc transpose data=bigxpo out=xpoxpo; id _name_; var col1; idl _label_; run;

Data typget; set xpoxpo; bignum=%utl_varlabel(xpoxpo,big); run;

%macro utl_varlabel(dsn,var)/des="Variable label"; %local dsid posv rc; %let dsid = %sysfunc(open(&dsn,i)); %let posv = %sysfunc(varnum(&dsid,&var)); %sysfunc(varlabel(&dsid,&posv)) %let rc = %sysfunc(close(&dsid)); %mend utl_varlabel;

or use datastep vtype, call label

%macro utl_vartype(dsn,var)/des="Variable type returns N or C"; %local dsid posv rc; %let dsid = %sysfunc(open(&dsn,i)); %let posv = %sysfunc(varnum(&dsid,&var)); %sysfunc(vartype(&dsid,&posv)) %let rc = %sysfunc(close(&dsid)); %mend utl_vartype;

On Jan 25, 6:19 pm, KevinMy...@AUSTIN.RR.COM (Kevin Myers) wrote: > Yes, FORCE was a late addition not included in my original proposal, but > necessary to make the proposed options and statements more useful. Using > the FORCE option would force TRANSPOSE to create appropriate attribute > variables even if no variable being transposed has a given attribute. For > example, with the current implementation, a LABEL variable (e.g. _LABEL_) is > only created if at least one of the variables being transposed actually has > a label. This can adversely complicate subsequent steps that must add extra > logic to alter processing depending upon whether or not the _LABEL_ variable > exists. Using FORCE would eliminate the need for such logic by causing the > LABEL variable to be created whether or not any of the variables being > transposed actually have a label. In this case, the LABEL variable would > have blank values for all observations. Make sense? > > s/KAM > > > > ----- Original Message ----- > From: "Ted Clay" <tc...@ashlandhome.net> > To: "'Kevin Myers'" <KevinMy...@AUSTIN.RR.COM>; <SA...@LISTSERV.UGA.EDU> > Sent: Monday, January 25, 2010 16:36 > Subject: RE: SASware ballot #18 Proc Transpose preserving variable > > attributes > > > Kevin, > > Did you mean to type "FORCE" on Proc Transpose? Did I miss a feature in > > your proposal? > > Ted > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Kevin > > Myers > > Sent: Monday, January 25, 2010 1:23 PM > > To: SA...@LISTSERV.UGA.EDU > > Subject: Re: SASware ballot #18 Proc Transpose preserving variable > > attributes > > > Oh come on Null... > > > As mentioned in the message, the example program is merely an > > overly-simplistic test case strictly intended to illustrate and exercise > > all > > of the necessary features. Any real application would include additional > > logic between the two transpose steps, or read the desired attributes > > values > > from a "self-defining" external file. > > > The real trick is for you to simulate the *second* transpose step with > > comparably simple code of your own. For you to say that the proposed > > TRANSPOSE enhancements are not needed, that is what you must be able to > > accomplish. So, are you up to the challenge? > > > ----- Original Message ----- > > From: "Data _null_;" <iebup...@GMAIL.COM> > > To: <SA...@LISTSERV.UGA.EDU> > > Sent: Monday, January 25, 2010 15:12 > > Subject: Re: SASware ballot #18 Proc Transpose preserving variable > > attributes > > >> On 1/25/10, Kevin Myers <KevinMy...@austin.rr.com> wrote: > >>> proc transpose data=original out=skinny type length format informat > >>> force > >>> noformat; by obsno; > >>> var _all_; run; > > >>> proc transpose data=skinny out=final noinformat; by obsno; > >>> id _NAME_; idlabel _LABEL_; idtype _TYPE_; idlength _LENGTH_; idformat > >>> _FORMAT_; idinformat _INFORMAT_; > >>> var col1; run; > > >>> If you can manage to accomplish something similar with code that is > >>> anywhere > >>> remotely close to something this simple, then you win a (virtual) > >>> cookie. > > >> Seems obvious: data=original- Hide quoted text - > > - Show quoted text -


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