BookmarkSubscribeRSS Feed
smart
Fluorite | Level 6

 

Cannot figure out how to import a cvs file. Appreciate any help.

 

My code:

 

options validvarname= any;

data Consumer;
proc import datafile="/courses/ddb976e5ba27fe300/NHANES 2013_2014/consumer.csv" out=Consumer dbms=csv replace;
getnames=no;
run;

proc contents data=Consumer;
run;

 

My errors:

ERROR: File WORK.CONSUMER.DATA does not exist.

ERROR: Import unsuccessful. See SAS Log for details.

 

 

My Task if needed:

 

The codebook, which shows the variable labels and formats, is available at:

https://wwwn.cdc.gov/Nchs/Nhanes/2013-2014/CBQ_H.htm

 

Import the consumer.csvdata into a temporary SAS data set called Consumer. The data values represent SEQN,CBD070,CBD090,CBD110,CBD120, and CBD130, respectively.

 

The variables in the Consumer data set should have permanently assigned variable labels.

3 REPLIES 3
Reeza
Super User
Comment your code and you'll find the error.
smart
Fluorite | Level 6

How do I do that?

Reeza
Super User

commenting your code means adding comments. 

 

In SAS you can add a comment using *; or /* */

 

*this is my comment;

proc means data=sashelp.class; 
class sex ; /*this is another comment*/
run;

It's considered good practice to comment your code. And I guarantee you'll save more time doing it because you'll find errors faster and avoid logical errors. And it's a good practice because it's hard to build in habits after you've already learned one way. 

 

So comment every line in your code with what you think it is doing and you'll likely find your mistake. If not, past back with your code and comments and I'll tell you where the issue is.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1126 views
  • 0 likes
  • 2 in conversation