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.
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:
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;
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.