BookmarkSubscribeRSS Feed
sasbegginer
Calcite | Level 5
Hi all,

I need to scan a column to find all the chacters within each string. The data is in hindi so they are all double byte characters. So what I need is really all the Hindi characters used on the column. I need a way of scan each string row and find the double byte character then output that chracter and then move on to the next character and so on...


Thanks in advance
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you review the SAS National Language Support (NLS) companion documentation. I expect you can use the SUBSTR function in a DO loop UNTIL you reach the LENGTH (function) of the SAS CHARACTER type variable.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search argument, this topic/post:

sas national language support dbcs unicode site:sas.com
sasbegginer
Calcite | Level 5
My sas is already setup to view the characters, but im not sure i would extract all the characters from the string....for exmaple

_row_
abcdefgh

output should be
a
b
c
d
e
g
h

remember in reality these are doubly byte characters. Thanks
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
What is _row_? Maybe a SAS column/variable? Definitely, I expect you can easily parse the SAS character variable using SUBSTR function, creating individual character variables/columns, as you require, also to generate individual observations within a DO / END using some IF THEN OUTPUT; logic within the DO/END paragraph, as suggested previously.

A straightforward DATA step program should accomplish the task as you have described.

Scott Barry
SBBWorks, Inc.
JasonS_SAS
SAS Employee
The "K" functions can be used to manipulated strings where a character may take more than one byte. For instance, you could use KLENGTH to get the length of the string, then pick characters out of the string with KSUBSTR in a loop. A log snippet showing this is at the bottom of this post.

Jason

[pre]
19 data _null_;
20 text = 'abcdef';
21 do i = 1 to klength(text);
22 c = ksubstr(text, i, 1);
23 put c;
24 end;
25 run;

a
b
c
d
e
f
[/pre]

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1367 views
  • 0 likes
  • 3 in conversation