BookmarkSubscribeRSS Feed
timgpp
Fluorite | Level 6

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 


Screen Shot 2016-09-10 at 8.52.34 PM.pngScreen Shot 2016-09-10 at 8.52.34 PM.png
8 REPLIES 8
Reeza
Super User

You need to list your variables in the input statement. Since you only lost two variables that's all it reads. 

timgpp
Fluorite | Level 6

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

Shmuel
Garnet | Level 18
Adding the option TRUNCOVER in infile statement, may help:

data
CitynameSTinSAS; infile "/folders/myfolders/CitynameSTforSAS.csv" dlm="," firstobs=2 TRUNCOVER; input Temp Met; run;
timgpp
Fluorite | Level 6

Maybe there is something wrong with my csv file then.  When I tried your suggestion Shmuel, I got the following message


Screen Shot 2016-09-11 at 9.49.13 AM.png
Shmuel
Garnet | Level 18

Can you open your CSV file with a text editor and upload a screenshot of it ?

Are you sure that FIRSTOBS should be 2 ?

Reeza
Super User

@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. 

 

Tom
Super User Tom
Super User

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;
timgpp
Fluorite | Level 6

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.  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1549 views
  • 0 likes
  • 4 in conversation