04-30-2018 02:55 AM
I have a dataset called new which have three columns
name age salary
when I am exporting this dataset into CSV through proc export
proc export data=new dbms=csv
when I am opening the CSV file it shows all the three columns in one column in CSV
But what i want all the three columns in three columns in CSV not in one column
How can I acheive that
04-30-2018 03:06 AM
You do have three "columns" here, separated by commas, which is what a CSV file is.
I take it you open this file in some Spreadsheet program like Microsoft Excel and want it to appear in three columns instead of 1?
You can do this either in Excel itself or by simply exporting the file as an .xlsx file to begin with.
Do a Google search, millions of examples there...
04-30-2018 04:04 AM
What is it you actually want? CSV = Comma Separated Variable file. This is one optional row with headers, each separated by commas, then one row per data line with data separated by commas. Which is exactly what you have there.
"when I am opening the CSV file" - and how and with what are you opening the file? If its association is with a text program like notepad then you will see it as plain text, if you associate it with Excel then Excel will open and parse it into a grid - this does not change the underlying structure or anything unless you save it.
04-30-2018 05:10 AM
working perfectly fine
data CSV_TEST; input name $ age salary; datalines; rohit 12 20000 sagar 15 50000 run; proc export data=Work.csv_test dbms=csv outfile=".....\sample.csv" replace; /*Add your Path*/ run;
04-30-2018 05:23 AM
04-30-2018 11:20 AM
CSV -> comma separated values.
Your file has comma separated values.
CSV files have no concept of 'columns'.
If you open the file in Excel, unfortunately, the default, it will show as three separate 'columns'. In this example it will work fine, but Excel can also misinterpret your data so be careful working that way.