BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
garag
Calcite | Level 5

Hi,

I need to concatenate some strings in order to create a command. This is the intial code

filename comando pipe "cd mylogdir; find . -mtime +1 -name '*.log'";

data listafile;
   infile comando truncover;
   input @1 nomefile $200.;
   if index(nomefile,'.log') or index(nomefile,'too long') then output;
run;

filename comando;

I would create the command


"cd mylogdir; find . -mtime +1 -name '*.log'";

dinamically, I mean a would read each parts of it from a dataset and concatenate them in order to create the complete command. Here you are my code

data dat;
  a='cd ';
  b='mylogdir';
  c='find . -mtime +1 -name *.log';
  old=a || b || c;
  put old=;
run;

%let mystring=;

data _null_;
  set dat;
  call symput('mystring',old);
run;

put mystring;

filename comando pipe &mystring;

but it does not work. Someone has an idea?

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I see three issues.

1) You left out the semi-colon seperator between the cd and find commands.

old = a || b || ';' || c;

2) You have not put the quotes in the find command.

c="find . -mtime +1 -name '*.log'";

3) You need to quote the string you use in the FILENAME statement.

filename comando pipe "&mystring";

or you could use the quote() function.

call symput('mystring',quote(trim(old)));

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

I see three issues.

1) You left out the semi-colon seperator between the cd and find commands.

old = a || b || ';' || c;

2) You have not put the quotes in the find command.

c="find . -mtime +1 -name '*.log'";

3) You need to quote the string you use in the FILENAME statement.

filename comando pipe "&mystring";

or you could use the quote() function.

call symput('mystring',quote(trim(old)));

garag
Calcite | Level 5

Thanks Tom, it worked.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2787 views
  • 0 likes
  • 2 in conversation