Date: Mon, 6 Dec 2010 15:24:47 -0500
Reply-To: Zibiao Zhang <zzhang@HSPH.HARVARD.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Zibiao Zhang <zzhang@HSPH.HARVARD.EDU>
Subject: Re: how to add labels from another file?
In-Reply-To: <AANLkTikzWmVpA6GAWVGYfS=ZonQB4nML6qDJXZzT4wyx@mail.gmail.com>
Content-Type: text/plain; charset=US-ASCII
Thank you, Joe, it worked very well.
Steven
>>> Joe Matise <snoopy369@gmail.com> 12/6/2010 2:51 PM >>>
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
|