BookmarkSubscribeRSS Feed
98ighcfdvxcghjk
Calcite | Level 5

Hello,

 

I am trying to have my SAS read my files but I am having trouble. I have this code below and it says the library does not exist when I run it but it worked before so now I am confused. IS there anyone who can help me with it and fixing the code so it runs?

/**this is the start of the prescribed medicine files for 2017 first**/

 

LIBNAME RX17 "C: Users\nidia\Documents\SASTHESIS";

FILENAME IN1 "C: Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp";

PROC XCOPY IN=IN1 OUT=RX17 IMPORT;

Run;

PROC CONTENTS DATA= RX17h197a;

TITLE "List of Variables SCRIPT 2017 MEPS";

Run;

 

/**start of the prescribed medicine files for 2018**/

 

LIBNAME RX18 “"C: Users\nidia\Documents\SASTHESIS";

FILENAME IN1 “"C: Users\nidia\Documents\SASTHESIS\RX18\H206a.ssp";

PROC XCOPY IN=IN1 OUT=RX18 IMPORT;

Run;

 

PROC CONTENTS DATA= RX18.h206a;

TITLE “List of Variables SCRIPT 2018 MEPS”;

Run;

6 REPLIES 6
Reeza
Super User

Are you getting any errors? What does the log show?

 

Make sure to paste your code into code blocks otherwise the HTML changes your code - is the missing slashes (see red below) in your path HTML changes or is it missing from the path?

 


@98ighcfdvxcghjk wrote:

Hello,

 

I am trying to have my SAS read my files but I am having trouble. I have this code below and it says the library does not exist when I run it but it worked before so now I am confused. IS there anyone who can help me with it and fixing the code so it runs?

/**this is the start of the prescribed medicine files for 2017 first**/

 

LIBNAME RX17 "C:\Users\nidia\Documents\SASTHESIS";

FILENAME IN1 "C:\Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp";

PROC XCOPY IN=IN1 OUT=RX17 IMPORT;

Run;

PROC CONTENTS DATA= RX17h197a;

TITLE "List of Variables SCRIPT 2017 MEPS";

Run;

 

/**start of the prescribed medicine files for 2018**/

 

LIBNAME RX18 “"C:\Users\nidia\Documents\SASTHESIS";

FILENAME IN1 “"C:\Users\nidia\Documents\SASTHESIS\RX18\H206a.ssp";

PROC XCOPY IN=IN1 OUT=RX18 IMPORT;

Run;

 

PROC CONTENTS DATA= RX18.h206a;

TITLE “List of Variables SCRIPT 2018 MEPS”;

Run;


 

98ighcfdvxcghjk
Calcite | Level 5

I added the slashes but I still get errors. This is the log:

 

18 /**this is the start of the prescribed medicine files for 2017 first**/
19
20 LIBNAME RX17 "C: \Users\nidia\Documents\SASTHESIS";
NOTE: Library RX17 does not exist.
21 FILENAME IN1 "C: \Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp";
22 PROC XCOPY IN=IN1 OUT=RX17 IMPORT;
23 Run;

WARNING: Library RX17 does not exist.
NOTE: Input library IN1 is sequential.
ERROR: Physical file does not exist, C:\Users\nidia\
\Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.


24 PROC CONTENTS DATA= RX17h197a;
ERROR: File WORK.RX17H197A.DATA does not exist.
25 TITLE "List of Variables SCRIPT 2017 MEPS";
26 Run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
27
28 /**start of the prescribed medicine files for 2018**/
29
30 LIBNAME RX18 “"C: \Users\nidia\Documents\SASTHESIS";
ERROR: Libref in LIBNAME statement must be followed either by quoted string or engine name or
semicolon; "“" found.
ERROR: Error in the LIBNAME statement.
31 FILENAME IN1 “"C: \Users\nidia\Documents\SASTHESIS\RX18\H206a.ssp";
ERROR: Error in the FILENAME statement.


32 PROC XCOPY IN=IN1 OUT=RX18 IMPORT;
33 Run;

ERROR: Libref RX18 is not assigned.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
34


35 PROC CONTENTS DATA= RX18.h206a;
ERROR: Libref RX18 is not assigned.
36 TITLE “List of Variables SCRIPT 2018 MEPS”;
37 Run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.

Reeza
Super User

It seems like the path is still wrong, it has an extra space in it.

 

Copy the path directly from Windows Explorer and paste it in. Hold down CTRL+SHIFT + RIGHT CLICK on a file and select copy as path and Windows will copy the full file path to your clipboard.

Run just the libname portion until that works correctly before running anything else.

 

 


@98ighcfdvxcghjk wrote:

I added the slashes but I still get errors. This is the log:

 

18 /**this is the start of the prescribed medicine files for 2017 first**/
19
20 LIBNAME RX17 "C:X\Users\nidia\Documents\SASTHESIS";
NOTE: Library RX17 does not exist.
21 FILENAME IN1 "C:X\Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp";
22 PROC XCOPY IN=IN1 OUT=RX17 IMPORT;
23 Run;

WARNING: Library RX17 does not exist.
NOTE: Input library IN1 is sequential.
ERROR: Physical file does not exist, C:\Users\nidia\
\Users\nidia\Documents\SASTHESIS\RX17\H197a.ssp.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.


24 PROC CONTENTS DATA= RX17h197a;
ERROR: File WORK.RX17H197A.DATA does not exist.
25 TITLE "List of Variables SCRIPT 2017 MEPS";
26 Run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
27
28 /**start of the prescribed medicine files for 2018**/
29
30 LIBNAME RX18 “"C: \Users\nidia\Documents\SASTHESIS";
ERROR: Libref in LIBNAME statement must be followed either by quoted string or engine name or
semicolon; "“" found.
ERROR: Error in the LIBNAME statement.
31 FILENAME IN1 “"C: \Users\nidia\Documents\SASTHESIS\RX18\H206a.ssp";
ERROR: Error in the FILENAME statement.


32 PROC XCOPY IN=IN1 OUT=RX18 IMPORT;
33 Run;

ERROR: Libref RX18 is not assigned.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
34


35 PROC CONTENTS DATA= RX18.h206a;
ERROR: Libref RX18 is not assigned.
36 TITLE “List of Variables SCRIPT 2018 MEPS”;
37 Run;

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.


 

98ighcfdvxcghjk
Calcite | Level 5

Thanks. The first part works now but I want SAS to read another file and that does not work in terms of the libname.

LIBNAME RX18 "C:\Users\nidia\Documents\SASTHESIS";

FILENAME IN2 "C:\Users\nidia\Documents\SASTHESIS\RX18\H206A.ssp";

PROC XCOPY IN=IN2 OUT=RX18 IMPORT;

Run;

 

PROC CONTENTS DATA= RX18.H206A;

TITLE “List of Variables SCRIPT 2018 MEPS”;

Run;

 

It gives me this in the log 

 

LIBNAME RX18 "C:\Users\nidia\Documents\SASTHESIS";
NOTE: Libref RX18 refers to the same physical library as RX17.
NOTE: Libref RX18 was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\nidia\Documents\SASTHESIS
121 FILENAME IN2 "C:\Users\nidia\Documents\SASTHESIS\RX18\H206A.ssp";
122 PROC XCOPY IN=IN2 OUT=RX18 IMPORT;
123 Run;

NOTE: Input library IN2 is sequential.
ERROR: File is probably a cport file. XPORT engine unable to read file created by proc cport.
Please use proc cimport to convert this file to native format.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.

 

Reeza
Super User

@98ighcfdvxcghjk wrote:

Thanks. The first part works now but I want SAS to read another file and that does not work in terms of the libname.

LIBNAME RX18 "C:\Users\nidia\Documents\SASTHESIS";

FILENAME IN2 "C:\Users\nidia\Documents\SASTHESIS\RX18\H206A.ssp";

PROC XCOPY IN=IN2 OUT=RX18 IMPORT;

Run;

 

PROC CONTENTS DATA= RX18.H206A;

TITLE “List of Variables SCRIPT 2018 MEPS”;

Run;

 

It gives me this in the log 

 

LIBNAME RX18 "C:\Users\nidia\Documents\SASTHESIS";
NOTE: Libref RX18 refers to the same physical library as RX17.
NOTE: Libref RX18 was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\nidia\Documents\SASTHESIS
121 FILENAME IN2 "C:\Users\nidia\Documents\SASTHESIS\RX18\H206A.ssp";
122 PROC XCOPY IN=IN2 OUT=RX18 IMPORT;
123 Run;

NOTE: Input library IN2 is sequential.
ERROR: File is probably a cport file. XPORT engine unable to read file created by proc cport.
Please use proc cimport to convert this file to native format.
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE XCOPY used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.


Did you try using PROC CIMPORT instead as suggested by the log? Code is very similar, see the docs link for more details.

 

libname newlib 'sas-library';
filename tranfile 'transport-file';
                  
proc cimport library=newlib infile=tranfile;
run;

 

 

ballardw
Super User

You have

LIBNAME RX17 "C: \Users\nidia\Documents\SASTHESIS";

but the space between : and \ is not valid

LIBNAME RX17 "C:\Users\nidia\Documents\SASTHESIS";

Also, have you created the folder SASTHESIS?

 

 

If you are working with a server then the server executing your SAS code likely does not see your hard drive as well.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1041 views
  • 4 likes
  • 3 in conversation