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

Hello,

 

I am using call scan to substring a variable to remove the last number from the string. I am receiving the Note: Invalid error to substring, although it seems to be working.

 

Have:

 Capture.PNG

 

Want:

 

Capture.PNG

 

here is my code:

 

call scan(_egtpt, -1, pos, length) ;
egtpt= upcase(substr(_egtpt,1, pos-2));

 

LOG:

Capture.PNG

Any help with clearing the note would be appreciated. Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
None of your examples generate an error with either your code or novinsorin's. I suspect you have some blank _egptpt entries and those records may be throwing an error.

View solution in original post

7 REPLIES 7
Reeza
Super User
Can you post an example of the error with the log notes? That usually helps with determining what the issue is a lot quicker.
mglogan
Obsidian | Level 7
Yes! updated post with image
novinosrin
Tourmaline | Level 20

If your variable value has just 1 digit value as the last value, you don't need call scan

want=upcase(substr(k,1,length(k)-2));

 

 

novinosrin
Tourmaline | Level 20

Try

 

data w;
k='Pre-Dose 2';
/*call scan(k, -1, pos, length) ;*/
want=upcase(substr(k,1,length(k)-2));
run;
Reeza
Super User
None of your examples generate an error with either your code or novinsorin's. I suspect you have some blank _egptpt entries and those records may be throwing an error.
mglogan
Obsidian | Level 7

Thank you! there were a few missing values. Works great now!

ballardw
Super User

If you copy code and/or error messages directly from your log you can paste the text into a codebox opened using the forum's {I} icon. Then edit anything you don't want to show such as XXXX for sensitive data. I think this may be easier than creating an image file, editing the image and the pasting the image in the forum.

 

Then we can also highlight or otherwise indicate directly in the text where a problem may be.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 7 replies
  • 783 views
  • 5 likes
  • 4 in conversation