BookmarkSubscribeRSS Feed
Ashish_S
Fluorite | Level 6

Dear All,

 

Could you please assist ? 

I need your asssustance to know how can we search if subscipt is available in data values of character variables in sas ?

 

For instance,   I have data values in my char variable in sas table like  service mark  and trademark ™  , In both the words you can see subcript .

 

so in case if i want to find wheather the word that i am reading have subcript or not then how can i do it in SAS? and then once find how to access and save in seperate variable.

 

Please assist.

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do they display that way in the dataset?  Just checking as some setups wouldn't show the superscript.

If it does then simple string processing functions like index, findw etc. should be sufficient.  Without some information however can't really go any furher.

http://support.sas.com/publishing/pubcat/chaps/59343.pdf

Ashish_S
Fluorite | Level 6

Hi RW9,

 

Thanks for your quick reply.

 

I am able to read those superscript in dataset(Attached file) but without searching specific superscript , Can we check wheather superscript is present in my variable data values.

 

data test1;
set test;
position=find(DrugName,'®');
run;

 

or

 

Saving the superscript in new variable:

 

data test2;
set test;
position=substr(DrugName,find(DrugName,'®'));
run;

 

Using the above code, I am able to find the position or save the subscript but here i am searching the specific superscript. But i dont know , list of posible superscript that could come in variable values. so i need to find if superscript is present or not.

 

Can we search ^ (superscript ) if present then retrive position without specifying any superscript present in data values.? Any specific function or statement that can be used to accomplish this task.

 

please assist.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, it doesn't work like that, there is no rtf tag ^{super} in the data, it runs of character sets.  All characters have a character table associated, e.g. ASCII, UTF16 etc.  These define what is displayed when the number (characters are actually a number refering to the table) is displayed when it encounters the number:

https://en.wikipedia.org/wiki/ASCII

https://en.wikipedia.org/wiki/UTF-32

http://www.fileformat.info/info/charset/UTF-16/list.htm

So if you know the character number for the super script characters then you can search for that.  I don't know offhand what these are, I strongly advise (and DM clean these things as well) that special characters do not appear in the data.  It can cause all kinds of problems.

Maybe this doc will help:

http://www.lexjansen.com/pharmasug/2010/CC/CC19.pdf

You could also try the compress() function e.g:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm

want=compress(have," ","acdf");
ShiroAmada
Lapis Lazuli | Level 10
data sample;
  symbol="This is the Copyright symbol"||'00A9'X;
  word=substr(symbol,1,find(symbol,'00A9'X));
  Unicode=substr(Symbol,find(symbol,'00A9'X);
run;
Ashish_S
Fluorite | Level 6

Hi ShiroAmada

 

Here in your example you are searching for specific supercript but i have many list of superscript.

 

In first step, can we check if supercript is present in data values or not? if it is present then store the position in variable.

 

is it possible?

Patrick
Opal | Level 21

@Ashish_S

Forget about superscript. That's formatting of characters which you won't have in your string of characters. The only thing you're having are characters so the only thing you can do is search for specific characters. 

What you would need is define the list of characters you're searching for (your "superscripts").

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 1018 views
  • 4 likes
  • 4 in conversation