Hi,
data data1;
input val_pas $20. ;
infile datalines truncover;
datalines;
substring\_'
;
run;
data data2;
input func $60. ;
infile datalines truncover;
datalines;
prxchange('s/[^0-9a-zA-Z.&_,\\\-\''\[\]\(\)\s]/^/', -1, val_pas)
;
run;
data output;
set data1 data2;
out_value=func;
run;
******************************************************************************
I want to call prxchange function and assign the out put to variable "out_value". For this function "val_pas" is one of the parameter(data1=Source text for regular expresion matching).
Is there any way to execute the function ?
Many thanks.
Regards
Hari.
Yes, you can create code using the call execute function:
data _null_; set data2; call execute('data output; set data1; out_value='||strip(func)||'; run;'); run;
You will need to read up on the call execute function, it is very powerfull, but you do need to know how to use it.
Yes, you can create code using the call execute function:
data _null_; set data2; call execute('data output; set data1; out_value='||strip(func)||'; run;'); run;
You will need to read up on the call execute function, it is very powerfull, but you do need to know how to use it.
That error is related to a flaw in your original program. The length of $60 is not long enough to hold the value that you are trying to read in. Correct the length and try again.
Well, top three google responses:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000543697.htm
http://www2.sas.com/proceedings/sugi22/CODERS/PAPER70.PDF
http://www2.sas.com/proceedings/sugi22/CODERS/PAPER86.PDF
Once you understand the concept its pretty simple and powerful. Basically the call execute takes a string, which inserted into the code stream after the datastep executing has finished. That text string will be considered code and compiled as any other code.
While the PRXCHANGE function does need to be compiled (i.e. can't be an expression) the arguments to the function can be expressions.
I believe that this is one of the uses for the RESOLVE function:
out_value = resolve(func);
It's untested, but I think it does what you're asking.
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.