BookmarkSubscribeRSS Feed
reef
Calcite | Level 5
is there a way to export sas variables to excel via dde when the variable names contain spaces? eg. put 'reporting month'n 'claim count'n. I have explored every idea using '09'x and @ and formats with the put statement but all failed.
7 REPLIES 7
Reeza
Super User

Include the NOTAB option in your file statement and you shouldn't have a problem. 

 

If you do, post your code. 

reef
Calcite | Level 5
It makes no difference. The notab option is included in both the filename
and file.

Filename xl dde "&xlfile." notab lrecl =2500;
Data _null_; set dat ; file xl notab; /* with or without */
If _n_ = 1 then put 'report month'n 'claim count'n;

##- Please type your reply above this line. Simple formatting, no
attachments. -##
FreelanceReinh
Jade | Level 19

It looks like you want to write those variable names as column headers to the Excel table. In this case the name literals don't make sense. Please try this:

if _n_ = 1 then put 'report month' '09'x 'claim count';

If something doesn't work, please provide more details (log messages, the output you get, ...)

reef
Calcite | Level 5
as i said previously, all ideas with '09'x, notab, @ etc were considered and all failed. there's no error in the log except that variables are not unitialised message due to spaces in variable names. here's a simple dataset for you to experiment on with the aim of writing it to excel. data d; format 'report month'n ddmmyy10.; 'report month'n = "1mar16"d; 'claim count'n = 1; output; 'report month'n = "1apr16"d; 'claim count'n = 2; output; 'report month'n = "1may16"d; 'claim count'n = 3; output; run; please note that I'm aware there are other ways to do this but I need this done using DDE.
reef
Calcite | Level 5
Finally it works! a combination of notab in the fielname statement and the naming of variables as Reeza suggested ie. 'REPORTING MONTH' '09'X 'CLAIM COUNT'; Thank you all.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Don't use DDE - its old (very), and not supported, plus doesn't work on some setups.  Plus you have all the limitations associated with Excel 95.  Why do you need to use it?  Proc export works ok, then there is tagsets.excelxp, which allows a lot of customisation even if it does create XML rather than a native XML XLSX file.  Then there is libname to Excel, then there is CSV, ... in fact there are so many options which are better than DDE.

Kurt_Bremser
Super User

Don't use blanks in variable names. Use the labels for descriptive text, and put those in your output when necessary.

Blanks in identifiers (variable names, file names etc) only cause additional work, make programs less readable and serve no purpose.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 1694 views
  • 0 likes
  • 5 in conversation