I have two datasets say DS_A and DS_B .
Both datasets contains 3 variables & 10 observations each.
I wish to export these datasets data to only one Excel file ( File_name : Sample.XLS, SheetName: Sheet1 )
I need to Export DS_A data to Sheet1 from A1:C10 cells and DS_B data to Same Sheet1 from A15:C25 cells .
the Challenge here is i shouldnt use DDE concept.
/*Sample Datasets*/
DATA INVENTORY;
INPUT PARTNUMBER $ DESCRIPTION $ INSTOCK @17 PRICE;
DATALINES;
K89R SEAL 34 245.00
M4J7 SANDER 98 45.88
LK43 FILTER 121 10.99
MN21 BRACE 43 27.87
BC85 CLAMP 80 9.55
NCF3 VALVE 198 24.50
KJ66 CUTTER 6 19.77
UYN7 ROD 211 11.55
JD03 SWITCH 383 13.99
BV1E TIMER 26 34.50
;
RUN;
DATA TOTAL;
INPUT CATEGORY:$ 15. TOTAL;
DATALINES;
STOCK_IN_TOTAL 1200
PRICE_IN_TOTAL 443.60
;
RUN;
Proc Export Data= Work.Inventory
Outfile= "C:\Users\U518651\Desktop\test\Inventory_Test.xls"
dbms=xls
replace;
sheet=TEST;
quit;
Proc Export Data= Work.Total
Outfile= "C:\Users\U518651\Desktop\test\Inventory_Test.xls"
dbms=xls
replace;
/*sheet=TEST;*/
Range='Test$A15:B16';
quit;
/*Sample Dataset*/
DATA INVENTORY;
INPUT PARTNUMBER $ DESCRIPTION $ INSTOCK @17 PRICE;
DATALINES;
K89R SEAL 34 245.00
M4J7 SANDER 98 45.88
LK43 FILTER 121 10.99
MN21 BRACE 43 27.87
BC85 CLAMP 80 9.55
NCF3 VALVE 198 24.50
KJ66 CUTTER 6 19.77
UYN7 ROD 211 11.55
JD03 SWITCH 383 13.99
BV1E TIMER 26 34.50
;
RUN;
/*Tried xlsx and sheet and range
still it gives error at Range*/
Proc Export Data= Work.Inventory
Outfile= "D:\SAS\Others\Inventory.xlsx"
dbms=xlsx
replace;
sheet=TEST;
Range='Test$A15:B16';
quit;
/*Tried xlsx and range
still it gives error at Range*/
Proc Export Data= Work.Inventory
Outfile= "D:\SAS\Others\Inventory.xlsx"
dbms=xlsx
replace;
Range='Test$A15:B16';
quit;
Can we use RANGE in Proc Export?
Your range is only two columns and two rows. How are you going to fit that dataset into that range?
Also try just setting the upper left hand corner on RANGE.
Are you on a Windows' operating system and, if so, is the use of VB script acceptable? If the answer to both questions is yes, there's a macro for that: http://www.sascommunity.org/wiki/A_Poor/Rich_SAS_Users_Proc_Export
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.