BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mauri0623
Quartz | Level 8
Spoiler
 

Hello,

 

How can I get each one of these print in a separate tab? The data contain a lot of rows and ods excel is not possible.

 

ods _all_ close;

ods csv file="C:/users/Mauri.Esfandiari/Documents/missing_ipac_odn_acc_tas.csv";

proc print data = work.missing_ipac_may18 noobs;

run;

title "Cases with missing ALCs";

proc print data = work.missing_odn_may18 noobs;

run;

title "Cases with missing Obligating Document Numbers";

proc print data = work.PSEUDO_ALCS_may18 noobs;

run;

title "Cases with Pseudo ALCs";

ods csvall close;

title;

 

When I run the code the title don't show up and the print statements are concatenated in one csv file.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
You open the ODS CSV destination, but you close the ODS CSVALL destination. I would expect this to cause problems because ODS CSV is still open.

To capture ALL titles in your CSV file (which may not be a good idea if you have a LOT of rows) you have to open ODS CSVALL and then close ODS CSVALL. However, a CSV file does not allow for the creation of multiple sheets in a single workbook. Only ODS TAGSETS.EXCELXP or ODS EXCEL will create multiple sheets in one workbook. I am not sure why ODS EXCEL is not possible unless you are not running SAS 9.4M2 or higher. But ODS TAGSETS.EXCELXP should be accessible as long as you have SAS 9 or higher.
Cynthia

View solution in original post

3 REPLIES 3
ballardw
Super User

CSV files do not have any concept of "tab". If you mean to open them in a spreadsheet that may not be a good idea if you mean by "lot of rows and ods excel is not possible" that there are too many rows to fit in Excel. Opening a CSV file with more rows than Excel wants to use the overage are discarded.

 

CSV files are intended for data interchange and as such "Titles" are not actually part of the content. A row of column headers and then the body of the data is the basic structure of a CSV file. Also a single CSV file basically assumes you know what you are doing when combining proc output as the result will be the output concatenated into a single file as you have found.

 

I think that you need to very clearly define what you want for output and possibly indicate how many records are in each of your data sets.

Cynthia_sas
SAS Super FREQ
Hi:
You open the ODS CSV destination, but you close the ODS CSVALL destination. I would expect this to cause problems because ODS CSV is still open.

To capture ALL titles in your CSV file (which may not be a good idea if you have a LOT of rows) you have to open ODS CSVALL and then close ODS CSVALL. However, a CSV file does not allow for the creation of multiple sheets in a single workbook. Only ODS TAGSETS.EXCELXP or ODS EXCEL will create multiple sheets in one workbook. I am not sure why ODS EXCEL is not possible unless you are not running SAS 9.4M2 or higher. But ODS TAGSETS.EXCELXP should be accessible as long as you have SAS 9 or higher.
Cynthia
Ksharp
Super User

ods csvall file="

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 1978 views
  • 0 likes
  • 4 in conversation