BookmarkSubscribeRSS Feed
Riteshdell
Quartz | Level 8

hello experts,

 

I need a help to solve a query. I have a dataset and column called NAME but this column Name has some kind of encoding data like .

 

I want to check which row has encoding data of ASC value which is falling between 161 to 255.

Suppose if you below code and data , so it should check each observation each string and identify the each string ASC value  and if any ASC value in observation is falling between 161 to 255, then a new column RANK_VALUE should give result of ASC Value,

if no value from 161 to 255, then null should pass.

 

data test;
input name $32.;
datalines;
RÃm
John
èra
©kumara
¶cris
;
run;
output :


Name   Rank_value

RÃm       195
John
èra       232
©kumara    169
¶cris       182
3 REPLIES 3
Riteshdell
Quartz | Level 8
rank procedure I ahev idea, but here each string we need to check . with array and loop we need to find out
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Random words, ahve no idea.

 

Functions work anywhere in arrays, or loops, anywhere in datastep.  Provide test data in the form of a datastep, show what the output should look like, explain the logic between the two.

data test;
  input name $32.;
  do i=1 to lengthn(name);
    rank_value=rank(char(name,i));
    output;
  end;
datalines;
RÃm
John
èra
©kumara
¶cris
;
run;

That might not actually do what you want however, try it out.  Some other possiblities:

http://www.sascommunity.org/planet/blog/category/rank/

29May example, shows compress removing specials, but you could reverse it with:

data want;
  set have;
  if lengthn(compress(name," ","ad"))>0 then result="special character";
run;

So remove the alaph and numerics then if the lengthn is greater than 0 you know you have odd characters.

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