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

Hi all,

I have a very long file name which SAS is unable to read (the file name gets cut in the middle). How can I keep the long file name?

I'm just using a data step, and a file statement.

I used the following code:

data _null_;

file "&filename";

I get an error during the run because the filename gets cut. I think I've used a %str function before to retain the long name, but I can't seem to get the code right.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Oh, the stupidity of users. (something I mutter under my breath, and often quite loud, at least 10 times a day).

In this case, try

file "'&filename'";

But I recommend putting up a sign:

"Every third user creating a directory with a blank is shot. Two were already warned."

View solution in original post

9 REPLIES 9
angeliquec
Quartz | Level 8

Hi Kurt,

Here it is:

%let filename = C:\Users\angelique.castaneda\Documents\Work\Practice Codes;

Yes, there is a space between Practice and Codes. In our production paths, some folder names have spaces which we cannot revise to put underscores instead.

Kurt_Bremser
Super User

Oh, the stupidity of users. (something I mutter under my breath, and often quite loud, at least 10 times a day).

In this case, try

file "'&filename'";

But I recommend putting up a sign:

"Every third user creating a directory with a blank is shot. Two were already warned."

angeliquec
Quartz | Level 8

Thank you Kurt!

Babloo
Rhodochrosite | Level 12

I tried like below in my SAS EG 5.1. But encountered by error as follows.

I can't guess the likely error in this code.

15         %let filename = "/data/PPM/Sample Check"; **unix folder

16         data _null_;

17         file "'&filename'";

NOTE: Line generated by the macro variable "FILENAME".

17          "'"/data/PPM/Sample Check"

               _

               23

ERROR 23-2: Invalid option name /.

CTorres
Quartz | Level 8

Remove the quotes in the %let statement:  %let filename = /data/PPM/Sample Check;

jakarman
Barite | Level 11

Do not use physical names that was. You can use them by defining a filename and then use  fileref(membername) .

---->-- ja karman --<-----
jakarman
Barite | Level 11

I would prefer using:

filename Angel "C:\Users\angelique.castaneda\Documents\Work\" ;

/* by an autoexec usermods as a standard for an application SASApp */

Then proceed:

file  Angel("Practice Codes") ;

/* to be used in the same way when needing anchors */ 

---->-- ja karman --<-----

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!

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.

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
  • 9 replies
  • 5245 views
  • 0 likes
  • 5 in conversation