Hey all,
The data that I need to work with is provided to me in a csv that contains all data in a single column of the csv. I can easily separate the data into columns in excel (thus obtaining all of the variables I need), but I need to find a way for SAS to separate the data into columns.
My csv contains in one column all data in this format:
month,year,country,cashflow
06,2018,Germany,23754
12,2011,France,567890
02,2003,Poland,788229
And I need to import the data into SAS so that it looks like this (without separating the columns in excel first):
month year country cashflow
06 2018 Germany 23754
12 2011 France 567890
02 2003 Poland 788229
Does anyone know how to do this directly in SAS? Thank you in advance
Very simple:
data want;
infile datalines dlm="," dsd truncover;
input month year country :$20. cashflow;
datalines;
06,2018,Germany,23754
12,2011,France,567890
02,2003,Poland,788229
;
Replace the DATALINES option of the INFILE statement with the path to your CSV file.
I am confused by your question. The file you posted looks like a normal CSV (comma separated values) file. Why do you say it has data in ONE column?
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.