%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
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.