I am trying to import data from a csv file into SAS studio. When I run the program, the notes tell me that there were zero observations and two variables. There are two variables, but there should be 39. What am I doing wrong? I have attached my code, as well as a screen shot of my csv file. Thank you for your help.
data CitynameSTinSAS;
infile "/folders/myfolders/CitynameSTforSAS.csv" dlm="," firstobs=2;
input Temp Met;
run;
Tim Muhich
You need to list your variables in the input statement. Since you only lost two variables that's all it reads.
Thank you for replying. I thought I had listed my variables; I only have two. It is just not bringing the data along with them. What am I missing in that statement to bring all of the temperature and metabolism data along with the variable names?
Thank you again for your time,
Tim
Adding the option TRUNCOVER in infile statement, may help:
data CitynameSTinSAS;
infile "/folders/myfolders/CitynameSTforSAS.csv" dlm="," firstobs=2 TRUNCOVER;
input Temp Met;
run;
Maybe there is something wrong with my csv file then. When I tried your suggestion Shmuel, I got the following message
Can you open your CSV file with a text editor and upload a screenshot of it ?
Are you sure that FIRSTOBS should be 2 ?
@timgpp In your first post you included two screenshots of your error message but not a screenshot of your CSV.
Include either the CSV or at the minimum a screenshot for help. It's likely an easy solution.
Your error message is saying that there 221 bytes, but no records in file past the first line. Perhaps your data is all on one line?
Try just telling SAS to read the file and show you want is in it.
data _null_;
infile '/folders/myfolders/CitynamesSTforSAS.csv' ;
input;
list;
run;
Then you can look and see what is there.
Perhaps the data is just all on one line?
data want;
infile '/folders/myfolders/CitynamesSTforSAS.csv' dsd;
input Temp Met @@;
run;
Thank you all for your help. You were right. It was the CSV file. Only the first line of the Excel sheet saved for some reason ( Thanks Tom for the tip about 221 bytes). I resaved the file as a CSV and it contained all the data. Life is good.
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.