DATA Step, Macro, Functions and more

SAS 9.4 dblabel error

Reply
Regular Contributor
Posts: 196

SAS 9.4 dblabel error

I tried adding dblabel=yes to my code.

My goal is to add labels to the variable names in EE_ActionOnly4 so that when I export this data the labels are exported as well.

data EE_ActionOnly4(dblabel=yes);

set EE_ActionOnly3;
run;

However, I received this error:

ERROR 22-7: Invalid option name DBLABEL.

 

Super User
Posts: 3,101

Re: SAS 9.4 dblabel error

I'm pretty sure this option is only valid when your DATA step is actually writing to the database you want it applied to and not prior to that. Here is an example:

 

http://support.sas.com/documentation/cdl/en/acpcref/69731/HTML/default/viewer.htm#n04dewltjfxt5un1cl...

 

Valued Guide
Posts: 505

Re: SAS 9.4 dblabel error

If you are talking about excel

Adding name and label to column headings in excel

HAVE
====

Up to 40 obs from sashelp.iris total obs=150

Obs    SPECIES    SEPALLENGTH    SEPALWIDTH    PETALLENGTH    PETALWIDTH

  1    Setosa          50            33             14             2
  2    Setosa          46            34             14             3
  3    Setosa          46            36             10             2
  4    Setosa          51            33             17             5
  5    Setosa          55            35             13             2

             Variables in Creation Order

#    Variable       Type    Len    Label

1    SPECIES        Char     10    Iris Species
2    SEPALLENGTH    Num       8    Sepal Length (mm)
3    SEPALWIDTH     Num       8    Sepal Width (mm)
4    PETALLENGTH    Num       8    Petal Length (mm)
5    PETALWIDTH     Num       8    Petal Width (mm)

WANT in EXCEL
=============

       [SPECIES]    [SEPALLENGTH]    [SEPALWIDTH]    [PETALLENGTH]    [PETALWIDTH]
         Iris        Sepal Length     Sepal Width     Petal Length     Petal Width
Obs     Species          (mm)            (mm)             (mm)            (mm)

123    Virginica          61              30               49              18
124    Virginica          61              26               56              14
125    Virginica          64              28               56              21
126    Virginica          62              28               48              18
127    Virginica          77              30               61              23


WORKING CODE
============

 SQL
    proc sql;
      select
        catx(' ',cats(name,'="[',name,']'),label,'"')
        sashelp.vcolumn
 PRINT
    proc print data=sashelp.iris label;
    label &namlbl.;

FULL SOLUTION
=============

proc sql;
  select
    catx(' ',cats(name,'="[',name,']'),label,'"')
  into
    :namlbl separated by ' '
  from
    sashelp.vcolumn
  where
         libname='SASHELP'
    and  memname='IRIS'
;quit;

ods excel file="d:/xls/namlbl.xlsx";
proc print data=sashelp.iris label;
label &namlbl.;
run;quit;
ods excel close;
Regular Contributor
Posts: 196

Re: SAS 9.4 dblabel error

With regards to trying to export data with its labels, I should have also added I need to use PC File Server to export the excel file.

Super User
Posts: 3,101

Re: SAS 9.4 dblabel error

So what is your full question then? You can assign a libname using the EXCEL engine and then add the DBLABEL to a DATA statement writing to the LIBNAME.

Ask a Question
Discussion stats
  • 4 replies
  • 171 views
  • 0 likes
  • 3 in conversation