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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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