DATA Step, Macro, Functions and more

editing path from a windows sas file to unix sas file

Reply
Super Contributor
Posts: 318

editing path from a windows sas file to unix sas file

I have some programs created in windows system and now will move them to unix system.

In the setup of the paths, like in the following example:

 

D:\proj\lMK30x211\cp110401\db\data\observed\shared\solid\2009\

to 

/Home/proj/lMK30x211/cp110401/db/data/observed/shared/solid/2009/

 

D: will be replaced by /Home and the back slash will be replace by forward slash.

 

I am thinking to use tranwrd to make these changes, but wonder if there is a better way to handle that. 

I have multiple projects to change so a more efficient way is expected. 

Super User
Posts: 5,430

Re: editing path from a windows sas file to unix sas file

Posted in reply to fengyuwuzu
What does the paths contain, and how/where are they defined?
Data never sleeps
Trusted Advisor
Posts: 1,022

Re: editing path from a windows sas file to unix sas file

Posted in reply to fengyuwuzu

Do you really want "/HOME" or do you want "~"?     /HOME is an absolute address, while ~ (in unix) refers to the home of your specific unix account (very handy for multiple user systems).  Note the ~ is NOT preceded by a forward slash.

 

As to changing the slashes, look at the TRANSLATE function.

 

Finally, you probably know this already but just in case: unlike windows, UNIX path specifications will be case sensitive.

Super User
Posts: 11,343

Re: editing path from a windows sas file to unix sas file

Posted in reply to fengyuwuzu

Do not assume that translating SAS code for file path or name information will work. The CODE will execute correctly on Windows regardless of case:

D:\proj\lMK30x211\cp110401\db\data\observed\shared\solid\2009\

would be considered the same as

D:\PROJ\LMK30X211\CP110401\DB\DATA\OBSERVED\SHARED\SOLID\2009\

on windows and unix will be very picky about every single letter.

Before you move them you may want to consider if your tools will consistently set case.

Super User
Posts: 19,817

Re: editing path from a windows sas file to unix sas file

Posted in reply to fengyuwuzu

Doesn't SAS automatically update the /\ as necesary or is that only on Windows?


fengyuwuzu wrote:

I have some programs created in windows system and now will move them to unix system.

In the setup of the paths, like in the following example:

 

D:\proj\lMK30x211\cp110401\db\data\observed\shared\solid\2009\

to 

/Home/proj/lMK30x211/cp110401/db/data/observed/shared/solid/2009/

 

D: will be replaced by /Home and the back slash will be replace by forward slash.

 

I am thinking to use tranwrd to make these changes, but wonder if there is a better way to handle that. 

I have multiple projects to change so a more efficient way is expected. 


 

Super User
Posts: 3,255

Re: editing path from a windows sas file to unix sas file

Posted in reply to fengyuwuzu

If you have a lot of file paths scattered through your code then an easy way to convert them is to use the SAS EG or Enhanced editor Find and Replace menu option. You don't need to use code to do this.

 

Also if your file paths are defining SAS libraries, I suggest moving these to a SAS AUTOEXEC program where you do them once only and then they can be available across all your SAS sessions. An even better practice if you share your libraries with other users AND your SAS environments are controlled by metadata servers would be to set these up in SAS Management Console.

Ask a Question
Discussion stats
  • 5 replies
  • 123 views
  • 0 likes
  • 6 in conversation