The SAS Output Delivery System and reporting techniques

output in csv format

Reply
Contributor
Posts: 20

output in csv format

I need an output in csv ,and my program is :

 

 

 

data_null_;

filename;

set;

file

delimiter=',' dsd 1rec1 = 350;

if_n_1 = 1

then do ;

 

put 'name'

      'date'

      'place'

      'gender'

;

end;

put name

      date

      place

      gender

     

      

;

run;

 

now my issue is when i open the ouput file either in excel or word pad 

 

name date place gender 

abcdef,09/09/2001,losangeles,male

 

how to arrange or reformat .,where there is no mention of size of variables in requiremnt .

Super User
Posts: 19,167

Re: output in csv format

I don't understand your question. What are you having issues with?
Contributor
Posts: 20

Re: output in csv format

name date place gender
abcdef,09/09/2001,losangeles,male

This how it appears when i try to open in word pad .
Super User
Posts: 19,167

Re: output in csv format

[ Edited ]

That's what a CSV file looks like, Comma Separated Values

 

What format do you want to see in wordpad?

Contributor
Posts: 20

Re: output in csv format

they are not in prorper rows i ,e date is not under date coilumn and so on
Super User
Posts: 19,167

Re: output in csv format

You didn't include comma's in your header column. Add comma's between the variable names and then open the file in Excel, it should look fine. If you want it to line up in columns in word pad that is NOT a CSV file, its a fixed width file format, that I would recommend avoiding. 

 

Also, you can use proc export instead of manually writing your datastep export if you'd like.

 

proc export data=have outfile="mycsv.csv" dbms=csv replace; run;

 

How do I write out a fixed-format file in SAS?

http://www.ats.ucla.edu/stat/sas/faq/write_fixedformat.htm

 

 

Contributor
Posts: 20

Re: output in csv format

If I don't include commas in header column ,
The output would be :
Abcdf,9:9/2001,losangeles n so nn
Super User
Posts: 19,167

Re: output in csv format

Please try it.
If _n_ =1 then Put 'name, date, place, Gender';

Ask a Question
Discussion stats
  • 7 replies
  • 564 views
  • 0 likes
  • 2 in conversation