%if &file2 = I1099TY %then %do;
%if &i = 2015 and &file2 = I1099TY and %qsubstr(&file3,1,5) = _2015 %then %do;
%let pfile3 = _2016;
%let sfile3 = %qsubstr(&file3,6,3);
%let file3 = %trim(&pfile3&sfile3);
I get a warning stating that the %qsubstr is out of range. &file3 = _201706
EDIT: Note that @Reeza has modified the subject line to be reflective of the question. Please try and use a descriptive subject line in the future.
Well, you don't exactly say what you want to achieve here. If this gives you the right answer, it would be a possible solution:
%let sfile3 = %qsubstr(&file3,6,2);
Yes, focus on this statement:
%let sfile3 = %qsubstr(&file3,6,3);
When &FILE3 is _201706, the sixth character is the second "0". If you start at that point, and attempt to take 3 characters, you will find that you run out of characters. There are only two characters left.
Sorry &file3 - _201507
So what is the fixing solution?
Well, you don't exactly say what you want to achieve here. If this gives you the right answer, it would be a possible solution:
%let sfile3 = %qsubstr(&file3,6,2);
If you want everything from including and to the right of the sixth character just use
%qsubstr(&file3,6)
Art, CEO, AnalystFinder.com
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.