www.sas.com > SAS UK > In the Know Homepage Search | Contact Us     
SAS UK Newsletter Banner SAS - The power to know(tm)  

When Using DDE to Output Data into an Excel File, How Do I Get Character Variables containing Spaces to Output into One Cell?
(Requested by Mark Ray, Barclaycard)

SAS expects to see a TAB character placed between each variable that is communicated across the DDE link. Similarly, SAS places a TAB character between variables when data are transmitted across the link. When the NOTAB option is placed in a FILENAME statement that uses the DDE device-type keyword, SAS accepts character delimiters other than tabs between variables.

The NOTAB option also can be used to store full character strings, including embedded blanks, in a single spreadsheet cell. For example, if a link is established between SAS and the Excel application, and a SAS variable contains a character string with embedded blanks, each word of the character string is normally stored in a single cell. To store the entire string, including embedded blanks in a single cell, use the NOTAB option.

Here is some sample code, a tab ('09'x) is added between each variable, as in the following PUT statement so that column1 contains 'Mark Ray' and column2 contains 'Jim Goodnight'.

filename test dde 'excel|sheet1!r2c1:r2c2' notab;
data string;
   file test;
   a='Mark Ray';
   b='Jim Goodnight';
   put a $15. '09'x b $15.;
run;
For additional BASE SAS sample code, please have a look at the following website:

For further information, please visit: http://ftp.sas.com/techsup/download/sample/samp_lib/hostsampBase_SAS_Sample_Programs.html