BookmarkSubscribeRSS Feed
kjohnson76
Calcite | Level 5

Hello,
I am not sure why, however I am hung up on Linux 'compress.' I can get a 'full path\filename', but my Linux parsing is not clicking.

I need to get my program name and its directory name into program macro var(s), compressing out punctuation and alpha char on Linux?  I know how to do this on SAS Windows but am new to linux.  Can someone show me the trick?

for example:
If I have directories (M20241, M20242) for yyyyq, each with 4 programs with names like myprog20241.sas - myprog2032.sas, etc (see below)
/work/M20241/
   myprog20241.sas     , If I run this program I want a &myCWD. holding 20241, and &myprog. 20241 for this file

   myprog20234.sas     , If I run this program I want a &myCWD. holding 20241, and &myprog. 20234 for this file etc. on down the list...
   myprog20233.sas
   myprog20232.sas
/work/M20242/
   myprog20242.sas     , If I run this program I want a &myCWD. holding 20242, and &myprog. 20242 for this file
   myprog20241.sas     , If I run this program I want a &myCWD. holding 20242, and &myprog. 20241 for this file
   myprog20234.sas     , If I run this program I want a &myCWD. holding 20242, and &myprog. 20234 for this file
   myprog20233.sas   , etc.

Just showing samples of have and want. However, I would like the directories to be able to be any legal Linux directory name that happens to have a single yyyyq string within it, and the same for the program, which happens to have a single yyyyq string within the name. I guess the only other restriction is there are no other numbers within each name.

-thank you

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

Some information is missing.

How do you use the macro variables?

Do you want to run all programs? Or choose just one?

How is the program run? 

What code do you have now that fails?

kjohnson76
Calcite | Level 5
I am sorry, I just want the macro variables set if I run the anyone program.
I do not care how, but typically we run them by hand. Sometimes we run them by cronjobs so if you want to share both starts that would be great, but one would get me past my mental blockage I am sure. (sorry that code is at work, I will have to share it later)
kjohnson76
Calcite | Level 5

Sorry, set internal to any given program for use with that program, but each program will be run within the current Q for all four back quarters.  (so I guess '%local' would be appropriate)

Tom
Super User Tom
Super User

I didn't really follow what your question was but perhaps it is related to this statement from your introduction?

 

 I can get a 'full path\filename', 

If by that you mean to imply that you are trying to use \  (backslash) as the delimiter between subdirectories then that will not work on Unix.  On Unix you use / (slash) as the delimiter between subdirectories.  The backslash is used to "escape" the next character.  So 

full path\filename

Just means:

full pathfilename

If you actually want to refer the filename in the directory full path then use:

full path/filename

 

kjohnson76
Calcite | Level 5
Sorry for the wrong slash. That was not my issue with my code at work...
ChrisNZ
Tourmaline | Level 20

What you want is still unclear.

So you have a bunch of files and you want to set 2 macro variables.

How these files and these variables are to be used is still unexplained.

Do you want to macro variables to show the location and name of the program when you run one of the programs?

If so, set the macro variables using the value of %sysfunc(getoption(sysin)) .

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 634 views
  • 0 likes
  • 3 in conversation