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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 959 views
  • 0 likes
  • 3 in conversation