LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2011, 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 Jul 2011 21:56:44 -0400
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: Create Labels based off Variable Names
In-Reply-To:  <CAL9q9TpTicU-MoOrtRqVVy4NY2B6NhGNp9mi3jLttAUBNxhq=w@mail.gmail.com>
Content-Type: text/plain; charset="US-ASCII"

Fareeza

You have had several suggestions. The following uses SQL to obtain a list of the variable names. Then, a data step parses these and creates the label equivalents. These are written to an external file which is then brought back in as code.

Nat Wooding

data one ; RETAIN PERIOD20111201 PERIOD20111202 PERIOD20091201 PERIOD20101202 'a'; Run ;

Proc SQL NoPrint ; Select name Into : SETvars Separated By " " From SASHelp.VColumn Where LibName = "WORK" And MemName = "ONE"

; Quit ;

Data _null_ ;

Array vars $ &SETvars ;

* desired format (FY11/12 P01,FY11/12 P02 ); filename out 'c:\temp.sas'; File out ; Put 'Label ' /; Do _I_ = 1 to Dim( VARS ); Target = vname( Vars(_I_) ); Yr = Substr( Target , 9 , 2 ); Mo = Substr( Target , 11 , 2 ); Period = compress( 'P' || Substr( Target , 13) ); str = Compress( 'FY' || Yr || '/' || Mo ); Str = Compbl( Str || Period || ' ' ); Put target '=""' str '""' / ; end; put ';'; run; Proc print data = one label; %INCLUDE out; RUN;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Fareeza Khurshed Sent: Wednesday, July 27, 2011 12:47 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Create Labels based off Variable Names

Hi,

I'm trying to create labels for certain variables based off the variable names.

I have variables PERIOD20111201 PERIOD20111202 which translates to FY11/12 P01 and FY11/12 P02.

I want the labels to show like above (FY11/12 P01,FY11/12 P02 ) and ideally like to accomplish this in a datastep.

Thanks, Fareeza


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