BookmarkSubscribeRSS Feed

Parsing strings into variables is a common task, and it takes a lot of coding to loop over a string, pull out the elements and convert them to variables of the right type. It would be nice to have something that works like the Parse Arg instruction in REXX, so a string could be passed with a template similar to the INPUT statement.


So I have a wish for the new year, a new Call Parse Routine. It would not fit into the general SAS syntax as a function, because the purpose is to create several new variables or assign new values to existing variables instead of returning a single value, but it should fit in implemented as a Call Routine:


                call parse (string,template);


The template is a string containing parse instructions with the same syntax as arguments to the Input statement excluding the trailing @ and @@, which wouldn't make sense in this case. A possible expansion of the syntax could be a way to specify an array name, so any array - including a temporary array - could have values assigned to all variables in one call.


1 Comment

Can you give an example or two to further explain this suggestion?