DATA Step, Macro, Functions and more

How to keep a long file name?

Accepted Solution Solved
Reply
Contributor
Posts: 55
Accepted Solution

How to keep a long file name?

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!


Accepted Solutions
Solution
‎11-17-2014 01:22 AM
Super User
Posts: 7,866

Re: How to keep a long file name?

Posted in reply to angeliquec

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."

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 7,866

Re: How to keep a long file name?

Posted in reply to angeliquec

Would you please post the %let filename= statement?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 55

Re: How to keep a long file name?

Posted in reply to KurtBremser

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.

Solution
‎11-17-2014 01:22 AM
Super User
Posts: 7,866

Re: How to keep a long file name?

Posted in reply to angeliquec

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."

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 55

Re: How to keep a long file name?

Posted in reply to KurtBremser

Thank you Kurt!

Super Contributor
Posts: 436

Re: How to keep a long file name?

Posted in reply to KurtBremser

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 /.

Super User
Posts: 7,866

Re: How to keep a long file name?

Pleas don't append your question to an already solved thread. Start a new one instead.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Regular Contributor
Posts: 180

Re: How to keep a long file name?

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

Trusted Advisor
Posts: 3,215

Re: How to keep a long file name?

Posted in reply to angeliquec

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

---->-- ja karman --<-----
Trusted Advisor
Posts: 3,215

Re: How to keep a long file name?

Posted in reply to angeliquec

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 --<-----
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 368 views
  • 0 likes
  • 5 in conversation