Hello
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
outfile="L\new\sample.csv" replace;
run;
when I am opening the CSV file it shows all the three columns in one column in CSV
name,age,salary
rohit,12,20000
sagar,15,50000
But what i want all the three columns in three columns in CSV not in one column
How can I acheive that
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...
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.
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;
I just opened this file with notepad++ and it is perfectly in three line and comma separated as below
name,age,salary
rohit,12,20000
sagar,15,50000
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.