| Date: | Wed, 31 Aug 2005 02:42:28 -0400 |
| Reply-To: | ben.powell@CLA.CO.UK |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | ben.powell@CLA.CO.UK |
| Subject: | Re: exporting labels instead of var names |
|---|
Conversely to strip variable labels (Richard DV):
%macro mac_delabel(ds);
proc contents data=&ds out=__out__;
run;
data _null_;
set __out__;
if _n_ = 1 then do;
lib = scan ("&ds",1,'.');
ds = scan ("&ds",2,'.');
if ds = '' then do;
ds=lib;
lib='WORK';
end;
call execute ('proc datasets nolist lib=' || lib || ';');
call execute ('modify ' || ds || ';');
end;
call execute ('label ' || name || '=" ";');
run;
proc datasets nolist lib=work;
delete __out__;
quit;
%mend;
On Tue, 30 Aug 2005 08:55:39 -0400, Venky Chakravarthy <swovcc@HOTMAIL.COM>
wrote:
>On Tue, 30 Aug 2005 01:07:52 -0700, Akramx <akram.chriai@GMAIL.COM> wrote:
>
>>Hello,
>> I used the export wizard to export my dataset to ACCESS. I was
>>wondering if it is possible to export the variable labels instead of
>>the variable names.
>>Thanks.
>
>Neither could I locate an option in the wizard, nor could I find anything
>in the proc export documentation to do this. This probably means the use of
>a kludge. See below for an example. I haven't tested extensively so use
>with caution. The key is to use the VALIDVARNAME option and then use meta
>data to rename the variable names to labels before exporting.
>
>data withlabel ;
> retain x 9 y "Why";
> label x = "This is my label"
> y = "Why" ;
>run ;
>
>options validvarname = any ;
>
>proc sql noprint ;
> select distinct trim(name) || "='" || trim(label) || "'n"
> into : renames separated by " "
> from dictionary.columns
> where libname = "WORK" and
> memname = "WITHLABEL" ;
>quit ;
>
>%put <<&renames>> ;
>
>data toexport ;
> set withlabel (rename = (&renames)) ;
>run ;
>
>Venky Chakravarthy
|