BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pwang14
Fluorite | Level 6

can anyone help me this out and provide me the details? I'm totally lost.

 

thanks


Capture.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:
As Reeza suggests, the ERROR message is accurately telling you what is wrong. You do not have a correct path to your CSV file.

I am not sure you followed ALL the code in the solution. I believe in the actual solution it has:
infile "&path/newemps.csv" dlm=',';

The &PATH is critical. It holds the name of the fully qualified path you are using. Remember in the very first Chapter of the book, the very first demo, you submitted a program to make the data. That program also makes the &PATH helper variable. Here are some examples:
%let path=/folders/myfolders; or
%let path=/folders/myfolders/ecprg193; <-- for SAS University Edition

%let path=c:\workshop\prg1; <-- Windows
%let path=/home/userid/prg1; <-- SAS On Demand

Next, your setup statements were supposed to include the LIBNAME for ORION:
libname orion "&path";

Because the &PATH helper variable is not just there for purposes of the LIBNAME statement, In Programming 1, we also intend for you to use &PATH in the INFILE statement to supply the fully qualified path.

Or, as an alternative, if you made the course files in C:\sas_class\pg1, then you could do this:
infile 'c:\sas_class\pg1\newemps.csv' dlm=',';

But that means every time you use an INFILE statement, you will have to remember and code the exact correct location.

cynthia


View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:
   That exercise is from the Programming 1 course, as we teach it in the classroom. The fact that this is a chapter 7 exercise tells me that this is from one of the older versions of the course. In the current version of the course, this exercise is in Chapter 8.

 

  The starter file for the course has the "beginning" statements you need -- if you got the programs that went with that edition of the course. IF you did not get the programs that go with the book, then you'll have to type approximately 7 lines of code.

 

  Here's a hint:
Data ?????;
   length ?????;
   infile ????? dlm=',';
   input ?????;
run;

proc print data=?????;
run;

 If you have the whole book with the exercise, and not just one page, then the solution to the exercise is at the end of the chapter. The Chapter in which this exercise occurs and the previous chapters on INFILE and INPUT and PROC PRINT should have adequate explanation of what all the above statements are for and how they need to be coded.

 

  However, if you are only trying to do the exercise, then here's the explanation:

1) you need a DATA statement to specify the name of the SAS dataset you are creating;

2) you need a LENGTH statement because without any other instructions, the default length of character variables will be 8 characters and the instructions specify you need longer lengths for all of the character variables;

3) you need an INFILE statement to point to the CSV file (you will probably find in the starter program p107e01.sas that the name of the starter file is newemps.csv)

4) you need an INPUT statement to "parse" the raw data lines and turn the raw data into SAS columns and observations

5) you need a RUN; statement as a step boundary to terminate the DATA step program

6) you need a PROC PRINT statement to start the print of the SAS data set you just created. So the name after data= will be the same as the name that appears on your DATA statement in #1

7) if all you want to do is test PROC PRINT, then you need another RUN; as the step boundary for the PROC PRINT step.

 

  If this is homework or you are taking the class from a professor you might want to ask your professor or teaching assistant for more specific help.

cynthia

pwang14
Fluorite | Level 6

Hi Cynthia,

 after I run the soulotions:

data work.NewEmployees;

       length First $12 Last $ 18 Title $ 25;

       infile 'newemps.csv' dlm=',';

       input First $ Last $ Title $ Salary;

run;

ERROR: Physical file does not exist, c:\Users\peng\newemps.csv.

 

proc print data=work.NewEmployees;

run;

 

how can i solve this problem?

Reeza
Super User

Read the error message. Do you have the text file in that location? If not, where is it? 

You have to include the full path to the CSV file.

Cynthia_sas
SAS Super FREQ

Hi:
As Reeza suggests, the ERROR message is accurately telling you what is wrong. You do not have a correct path to your CSV file.

I am not sure you followed ALL the code in the solution. I believe in the actual solution it has:
infile "&path/newemps.csv" dlm=',';

The &PATH is critical. It holds the name of the fully qualified path you are using. Remember in the very first Chapter of the book, the very first demo, you submitted a program to make the data. That program also makes the &PATH helper variable. Here are some examples:
%let path=/folders/myfolders; or
%let path=/folders/myfolders/ecprg193; <-- for SAS University Edition

%let path=c:\workshop\prg1; <-- Windows
%let path=/home/userid/prg1; <-- SAS On Demand

Next, your setup statements were supposed to include the LIBNAME for ORION:
libname orion "&path";

Because the &PATH helper variable is not just there for purposes of the LIBNAME statement, In Programming 1, we also intend for you to use &PATH in the INFILE statement to supply the fully qualified path.

Or, as an alternative, if you made the course files in C:\sas_class\pg1, then you could do this:
infile 'c:\sas_class\pg1\newemps.csv' dlm=',';

But that means every time you use an INFILE statement, you will have to remember and code the exact correct location.

cynthia


SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1844 views
  • 4 likes
  • 3 in conversation