BookmarkSubscribeRSS Feed
ngunan0921
Calcite | Level 5

Hi there! 

I'm asked to do the following below in SAS Visual Analytics. I'm using SAS Viya for Learners 3.5. 

 

ngunan0921_0-1698653333348.png

This is what I have so far. it looks good in the beginning but once I reach the later parts of the data, the string I want isn't correctly extracted. I need assistance on how to extract part of a string before a delimiter. In this case, before the colon. 

ngunan0921_1-1698653526584.png

ngunan0921_2-1698653769644.png

Thanks in advance. 

 

3 REPLIES 3
Stu_SAS
SAS Employee

You are very close! This looks like a learning exercise so I won't give the answer away entirely, but I'll give you a hint. Consider that the length of the substring before : varies in length:

10-5:23.6,-51.2
10-100:23.6,-51.2

 

If you could find the position of the :, then you would know exactly how long your substring needs to be:

10-5:23.6,-51.2
^
5
10-100:23.6,-51.2
^
7

Is there another function that can help you do this?

ngunan0921
Calcite | Level 5

It took me some time to figure it out. I thought it was the getlength at first but I realized it's the findchar. 

thanks for the hint!

Stu_SAS
SAS Employee

Bingo! Awesome work 😃

Substring('from_loc'n, 1, FindChar('from_loc'n, ':')-1)

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 980 views
  • 2 likes
  • 2 in conversation