Hallo.
I have a file '~/test.sas' which contains one line
%metalibm(inlibdw); * Bankdata DW;
when i run
data test2;
infile "~/test.sas" truncover;
input line $char100.;
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,line);
run;
I get end_=0.But if I input the line in a dataset
data test3;
line=' %metalibm(inlibdw); * Bankdata DW;';
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,line);
run;
I get end_=50 wich is corret.
Any idea of why this happens?
You seem to be comparing apples to oranges here.
Change your second data step to define LINE as being of length $100 so that it matches how SAS guessed you wanted the variable defined in the first data step.
Your REGEX needs to account for the trailing spaces that will be present in a SAS variable.
You seem to be comparing apples to oranges here.
Change your second data step to define LINE as being of length $100 so that it matches how SAS guessed you wanted the variable defined in the first data step.
Your REGEX needs to account for the trailing spaces that will be present in a SAS variable.
trim(line)
Hi,
consider the trailing blanks in your line variable with length=100.
You are expecting a semi-colon at end of line, but you have a semi-colon followed by blanks instead
Consider adding \s* to your regex or use strip(line) in prxmatch
data test3;
line=' %metalibm(inlibdw); * Bankdata DW;';
commentEnd=prxparse('/(\*\/|;$)/');
end_=prxmatch(commentEnd,strip(line));
run;
Edit: or trim(line) like @data_null__ said
- Cheers -
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.