DATA Step, Macro, Functions and more

Proc print noobs | Proc SQL select *

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

Proc print noobs | Proc SQL select *

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!


Accepted Solutions
Solution
‎12-26-2014 02:03 AM
Respected Advisor
Posts: 4,173

Re: Proc print noobs | Proc SQL select *

Posted in reply to krishmar1

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


All Replies
Respected Advisor
Posts: 4,934

Re: Proc print noobs | Proc SQL select *

Posted in reply to krishmar1

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

PG
Contributor
Posts: 34

Re: Proc print noobs | Proc SQL select *

WIDTH=MINIMUM in PROC PRINT did not help.

Thanks!

Respected Advisor
Posts: 4,173

Re: Proc print noobs | Proc SQL select *

Posted in reply to krishmar1

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?

Contributor
Posts: 34

Re: Proc print noobs | Proc SQL select *

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!

Super User
Posts: 10,044

Re: Proc print noobs | Proc SQL select *

Posted in reply to krishmar1

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

Solution
‎12-26-2014 02:03 AM
Respected Advisor
Posts: 4,173

Re: Proc print noobs | Proc SQL select *

Posted in reply to krishmar1

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).

Contributor
Posts: 34

Re: Proc print noobs | Proc SQL select *

Thank you, Patrick.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 1098 views
  • 0 likes
  • 4 in conversation