Date: Mon, 6 Dec 2010 13:51:12 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: how to add labels from another file?
In-Reply-To: <201012061945.oB6Gq5If013490@willow.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Steven,
You can create code from the second file to execute in PROC DATASETS a
number of ways - write it to a temp file, use CALL EXECUTE, etc.
For example (not tested):
filename a temp;
data _null_;
set labelfile;
file a;
string=catx(' ','label',varname,'=',label,';');
put string;
run;
proc datasets lib=work;
modify datasettomodify;
%include a;
quit;
or
data _null_;
set labelfile end=eof;
string=catx(' ','label',varname,'=',label,';');
if _n_ = 1 then do;
call execute("proc datasets lib=work; modify datasettomodify;");
end;
call execute(string);
if eof then do;
call execute("quit;");
end;
run;
Possible proc datasets syntax errors aside, that should accomplish what
you're trying to accomplish.
-Joe
On Mon, Dec 6, 2010 at 1:45 PM, Steven Chang <zzhang@hsph.harvard.edu>wrote:
> Hi all,
> I have one data set with many variables without labels.
> I have another data set which has two variables: variable_name and label.
>
> How can I add the labels in the second file to my first data sets?
>
> Thanks,
> Steven
>
|