I have a dataset that has multiple "types" that I need to export to and append to different excel sheets.
Data:
Type Dist1 Dist2 Dist3
A 0 0 2
B 1 1 23
C 23 32 45
Excel Workbook has 3 sheets (A, B, C) All "A" data each week needs apppended to the "A" sheet and so forth.
Suggestions?
Thanks
Kyle
Use PROC EXPAND with a (where=(Type='A')) option.
For the append part of your program, check out the code in this article
Run a PROC EXPORT to create a sheet when TYPE='A'
Run another PROC EXPORT to the same Excel file to create a different sheet when TYPE='B'
Repeat as needed
@PaigeMiller i love that. Cheers! lol
Yes, I knew I could write multiple export statements did not know if they could be combined in anyway to shorten coding as I have lets say 26 types that all go to different sheets in different workbooks. But if not then I will write the multiple lines of code.
This is an example where a macro could loop through all "types" and get the job done.
... if they could be combined in anyway to shorten coding as I have lets say 26 types that all go to different sheets in different workbooks ...
Sure would have been helpful to mention this in your first message.
Loop makes sense.
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.
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.