Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export varibles(labels) to excel from SAS data set 1

Status
Not open for further replies.

anoos127

Programmer
Sep 26, 2006
2
US
Hi

I am trying to export variables along with calculated observations to excel from a SAS data set using PROC EXPORT.Its working fine.

ERROR: I am trying to expoet LABLES defined for variables in dataset to excel.I aam having problem with this.
AS ITS A RESTRICTION THAT WE CANNOT EXPORT LABELS USING PROC EXPORT TO EXCEL , can you please suggest any alternate technique that I can use to export labels from DATASET to EXCEL.

Thanks,
Ashu
 
One method would be to get the info from Dictionary.columns:-
Code:
data test;
  label var1 = 'This is the Label';
  var1 = 'This is the value';

run;


proc sql noprint;
  select UPCASE(LABEL)
    INTO :labels separated by ' '
  from dictionary.columns
  where LIBNAME = UPCASE("WORK")
    and MEMNAME = UPCASE("test")

    ;
%put &labels;
You could also write that out to a dataset rather than a macro variable. After that you'll have to play with it to get it written out correctly, possibly as a header row...

I'm working on the assumption that you've looked at the documentation for Proc Export and made sure that there's no option that allows you to do this directly. If that's not correct, check out the online doco
 
Actually, an alternative method comesw to mind.
Use Proc Print or proc report to print out your dataset and use the ODS EXCELXP tagset to write out the data to an Excel spreadsheet with the labels...
 
Thanks Chris I will try this.Hope this works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top