Search code examples
sassas-macro

Display a letter from a particular string


I have a excel sheet which contains certain string want to display the letter according to my examples required output.

below is the code i tried to get my desired output? help to make changes to my code any help is appreciated....

data test;
set work.rr;
full=scan(full,-5);
run;

Solution

  • Use the scan() function, but with a negative 2nd parameter, i.e. working backwards from the end of the string, and remember to specify the delimiter, i.e. \ :

    data want ;
      set have ;
      prefix = substr(scan(full,-2,'\'),1,1) ;
    run ;