BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mauri0623
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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);

View solution in original post

6 REPLIES 6
Astounding
PROC Star

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.

mauri0623
Quartz | Level 8

Sorry &file3 - _201507

mauri0623
Quartz | Level 8

So what is the fixing solution?

Astounding
PROC Star

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);

mauri0623
Quartz | Level 8
Thank you much. This got rid of the warning.
art297
Opal | Level 21

If you want everything from including and to the right of the sixth character just use

%qsubstr(&file3,6)

Art, CEO, AnalystFinder.com

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 978 views
  • 1 like
  • 3 in conversation