Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV Titles

Status
Not open for further replies.

SPhill

Programmer
Sep 17, 2003
32
GB
I'm using 'put (_all_)(',');' to export all variables into a CSV file, however I need to put column headers in the file as well. I'm holding about 200 columns of data from a previously defined macro:-
" %MACRO INPUTCD ;
%DO I=1 %TO 200;
@1391 + ((&I-1)*2) IFCODE&I ib2. "
Is there a way of getting the column titles in without having to do " put 'ifcode1,' 'ifcode2,' " etc etc up to 200. I was hoping the above %ifcode would work as " '%ifcode,' " but no joy it just prints "%ifcode". 'ifcode:' doesn't work either.

Anyone know a quick fix?

Thanks

Scott

 
The problem I have with your method (Using the PUT _all_ function) is two fold.
1) Your data may have comma's internally (inside the column) and will nudge that row out of sync.
2) The put _all_ does not put the vars out in an order that is reliable. On some occasions I have seen it use column order on others it put it in alpha order.

Why not use the ODS engine.
ex.
ODS CSV file="your_file.csv";
proc print data=yourds;
run;
ods csv close;

If you need to use a non ODS method to generate this text file, I have several ways you can do this. Please send us some more information. Not just a small snap shot of code thats buried deep in some other program.
 
ODS CSV did the trick, works perfectly.

Thanks

Scott
JCL TSO MVS SAS 8.2

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top