BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
krishmar1
Fluorite | Level 6

Hi,

I exported a SAS data set to a .csv file using ODS csv file statement. I tried 2 different options : first, I used proc print noobs without a var statement. Then, I used Proc sql select * statement. I got 2 .csv files of different sizes. The first file was considerably bigger than the second file. I opened the 2 .csv files. They looked the same with the same number of rows and columns.

Since I exported the same data set, shouldn't the size be the same in both cases? Is there a difference between Proc print noobs and Proc SQL select * as far as the output is concerned?

Thanks!

Happy Holidays!

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

The numeric variables in sashelp.class have no formats associated.

Looking at the output PROC SQL generates in comparison to PROC PRINT it appears that Proc Print "uniforms" it's output so that "height" and "weight" are always printed with the same number of decimals. PROC SQL on the other hand only prints as many decimals as required so the number of decimals per row differs (=in total less characters written to output).

View solution in original post

7 REPLIES 7
PGStats
Opal | Level 21

It probably has to do with the width of the columns. Try adding option WIDTH=MINIMUM to proc print. - PG

PG
krishmar1
Fluorite | Level 6

WIDTH=MINIMUM in PROC PRINT did not help.

Thanks!

Patrick
Opal | Level 21

Please provide your code - eventually creating output using sashelp.class or something similar - so we can replicate what you describe instead of having to guess what you might be doing.

I assume you've got the different sizes because of different column widths and/or leading/trailing blanks in the output lines. Have you looked into your output using something like Notepad++ showing you the actual characters in the file including blanks?

krishmar1
Fluorite | Level 6

Here's my code:

ods listing close;

ods csv file= ".../class_sql.csv" ;

proc sql;

select * from sashelp.class  ;

quit;

ods csv file= ".../class_print.csv" ;

proc print data=sashelp.class noobs;

run;

ods csv close;

ods listing;

Thanks!

Ksharp
Super User

You could check lrecl if they are the same by Notepad++ . Maybe that was the reason.

Patrick
Opal | Level 21

The numeric variables in sashelp.class have no formats associated.

Looking at the output PROC SQL generates in comparison to PROC PRINT it appears that Proc Print "uniforms" it's output so that "height" and "weight" are always printed with the same number of decimals. PROC SQL on the other hand only prints as many decimals as required so the number of decimals per row differs (=in total less characters written to output).

krishmar1
Fluorite | Level 6

Thank you, Patrick.

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