BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8

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.

 

4 REPLIES 4
SASKiwi
PROC Star

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...

 

rogerjdeangelis
Barite | Level 11
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;
gzr2mz39
Quartz | Level 8

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.

SASKiwi
PROC Star

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1531 views
  • 0 likes
  • 3 in conversation