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.
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.
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.