BookmarkSubscribeRSS Feed
overky
Calcite | Level 5

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

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Use PROC EXPAND with a (where=(Type='A')) option.

 

For the append part of your program, check out the code in this article

 

http://www2.sas.com/proceedings/sugi31/024-31.pdf

PaigeMiller
Diamond | Level 26

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

--
Paige Miller
novinosrin
Tourmaline | Level 20

@PaigeMiller i love that. Cheers! lol

overky
Calcite | Level 5

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.

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
overky
Calcite | Level 5

Loop makes sense.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2133 views
  • 1 like
  • 4 in conversation