13
Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Embed Size (px)

Citation preview

Page 1: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Page 2: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

Presentation Outline

What is DDEDDE commandDDE ImportDDE Export

Illustration of DDE usage in PMS studiesRead data from XLSGenerate output tablesGenerate data validation relative documents

Some perspectives on appropriately usage of DDE

Page 3: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

What is DDE

Available after SAS 6.08 Release (1993)http://www.sas.com/presscenter/bgndr_history.html

DDE is a communication protocol(TS325)ftp://ftp.sas.com/techsup/download/technote/ts325.pdf

ftp://ftp.sas.com/techsup/download/pc/ts325.pdf

Things that can be done manually in Excel can be automated from SAS code

Page 4: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

What is DDE – DDE Command

Start EXCEL* A prerequisite for using DDE is that both client and server applications are up and running.

Introduction of two type of StartupX ‘’;

Wait for opening of EXCEL

%startxl();Roper (2000):

MS Office must be registered in SYSTEM

Page 5: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

What is DDE – DDE Command

Doublet-Style DDE filereffilename sas2xl dde 'excel|system';

Triplet-Style DDE filereffilename recrange dde 'excel|[VBA.xls]sheet1!r4c1:r103c4' notab;

Difference of Doublet and Triplet reference nametriplet gets buffered during data step execution, and is only pumped through the DDE connection when the data _null_ step terminates. (example for CRFIMG)immediately passed on to Excelexample of ‘FLUSH’ statement

Page 6: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

What is DDE – Import from Excel

Proc ImportBugs of SAS8.2 & Office2003 (DoubleByteCharacter issues)

Sheet Name with BLANK

Mixed column

DDECan not work under UNIX

Alt+0010 soft carriage return

Be cautious when used with CSV

Page 7: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

What is DDE – Export to Excel

Proc ExportUnder UNIX DBMS option is special;

DBMS=XLS not EXCEL/EXCEL97/EXCEL2000

path should be like: “~ / a.xls”

DDECan not work under UNIX

Not very efficient

Office 2003 issues

Page 8: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

Update Excel to Ver. 2003

We got trouble with Office2003 !!

Export (format collapse)Merge cells of different rows

Solution:Key Token Sending

VBA

VBS

VB

JAVA

Inport (DBC problem)

Page 9: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

DDE and VBA

DDE work with X4ML not VBA

Can not write VBA macro directly into EXCEL;

Can open spreadsheets with VBA macros;

Can write X4ML into spread sheet then execute it;

Page 10: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

Excel – Java – SAS9

JXL API (Java Excel Api)Mature open source API enabling read/write/modifiy Excel spreadsheets

http://jexcelapi.sourceforge.net/

SAS9 Assign a sas libref to XLS directlyLibName test excel "\\path\fileName.xls"

Page 11: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

Template and Pure Code for Output

Pure CodeGenerate all format and values with pure SAS code

More flexible (formats can automatically changed with titles, footers, columns etc.)

Require higher DDE skills

Require powerful macro supporting

More efficient with macros well prepared

TemplateCreate Template Manually

Insert data into template with SAS DDE code

Easier to be used

Workload can be distributed

Quicker under urgent situation

Page 12: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

SAS帝国的暴力美学

Page 13: Jack 2008-03-13 Working with Excel - Usage of Dynamic Data Exchange in PMS studies

Jack 2008-03-13

References

MacroFun.hlp (X4ML languange help)

Koen Vyvermanhttp://www.sas-consultant.com/professional/papers.html