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 -
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.