BookmarkSubscribeRSS Feed
Coding4you
Obsidian | Level 7

Hi All,

 

I was wondering is there a way to proc export a data if the data set name = this (as a pipe delimited txt file) else export as a CSV. 

thank you!

7 REPLIES 7
SASKiwi
PROC Star

An easy way is to set a default parameter on a macro then no conditional logic is required:

%macro MyExport (dataset =
                ,filename =  
                ,DLM = ','
               );
proc export data = &dataset
            file = "\MyFolder\&filename"
DLM = &DLM ; run; %mend MyExport; %MyExport (dataset = MyCSV, filename = \Myfolder\MyCSV.csv); %MyExport (dataset = MyPipe, filename = \Myfolder\MyPipe.csv, DLM = '|');
Coding4you
Obsidian | Level 7
Thank you
Coding4you
Obsidian | Level 7
Thank you
Coding4you
Obsidian | Level 7

Hi Kurt,

 

Can I also ask is there a way to output the file in a txt file if its’s pipe delimited and csv if it’s in comma in that same piece of codes you provided below? 

thank you,

kelvin.

SASKiwi
PROC Star

@Coding4you  - Look at the macro code I posted.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 7 replies
  • 1709 views
  • 2 likes
  • 3 in conversation