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!
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).
It probably has to do with the width of the columns. Try adding option WIDTH=MINIMUM to proc print. - PG
WIDTH=MINIMUM in PROC PRINT did not help.
Thanks!
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?
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!
You could check lrecl if they are the same by Notepad++ . Maybe that was the reason.
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).
Thank you, Patrick.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.