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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1664 views
  • 0 likes
  • 2 in conversation