BookmarkSubscribeRSS Feed
fengyuwuzu
Pyrite | Level 9

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/

 

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

5 REPLIES 5
LinusH
Tourmaline | Level 20
What does the paths contain, and how/where are they defined?
Data never sleeps
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ballardw
Super User

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.

Reeza
Super User

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/

 

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


 

SASKiwi
PROC Star

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.

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