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 (July 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 28 Jul 2004 21:38:54 -0400
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: Copying label from one variable to another

Stanley Fogleman wrote: > Is it possible to copy the label from var1 to var2 in the same data > step? I can't seem to get past the syntax requirement that the label > statement requires a string inside single or double quotes. Ordinarily > I would assign a macro variable, but then you run into data step > boundary issues. > sample code: > data temp; > retain bogus_label '123456789012345678901234567890'; > set previous; > bogus_label = vlabel(var1); > label var2 = ???????

There is no function that will let you set the pdv label at runtime. In general, the program statements of a data step that is running cannot affect the header of the output tables being created by the DATA statement. The header contains information about each variable; the name, type, length, format, informat, label, constraints, etc...

You can store the label in a macro variable and use that in a Proc DATASETS following the Data Step.

data foo; attrib bar length=$8 label='The label of "bar"'; bar='abc'; run;

data foo2; set foo; xyz = 100; if (_n_=1) then call symput ('barLabel', vlabel(bar)); run;

proc datasets nolist lib=work; modify foo2; label xyz=%sysfunc(quote(&barLabel)); quit;

Other techniques might use Proc CONTENTS or SQL DICTIONARY.COLUMNS

-- Richard A. DeVenezia http://www.devenezia.com/downloads/sas/samples/


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