SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
Abraham
Obsidian | Level 7

Hi,

I want to find single quote (') and long hyphen :smileyminus: in a CLOB data.

I used index function but its not working.

When I am trying to keep  long hyphen in the sas editor to start programming, it is automatically changed into small hyphen and the program capture record with small hyphen.

Can anyone help me

data abc;

  informat string $100.;

   input id string &;

  cards;

1 patient’s hemoglobin was less than or equal to 11 (units not provided). On an unknown date in May 2013

2 A former school cricket-coach was jailed for 15 months on Thursday for normal@range.

3 A 19 derivation EEG demonstrated theta activity (5−6 c/sec) on right frontal derivations corresponding to the lesion site

4 The neurological examination at'admission showe'd a stuporous state with partial cluster seizures

5 The Singapore Armed Forces (S−A−F) will conduct military exercises in Seletar

;-

Output should be Id number 1, 3 and 5

Advance thanks

3 REPLIES 3
allurai0412
Fluorite | Level 6

hi,

Long hypen   or 'em dash '  are special chcarcters ..

Go to MS-word and replace     -  with     —    /* i have pasted  long hypen from ms word*/

.....go with following code..

data want;

set abc;

if find(trim(string),'—') then _id=id;       /* i have pasted  long hypen from ms word*/

run;

Regards,

Allu

Message was edited by: Y ALLU

Robert
Fluorite | Level 6

Here's a snippet of code I wrote the other day to help someone with a similar problem.

data test;

set your_dataset;

length new_category $5 category1-category3 $7;

category1 = cat('0 ', byte(150), ' 5');  * USE 150 for an EN (short) DASH and 151 for an EM (long) DASH;

category2 = cat('6 ', byte(150), ' 10');

category3 = cat('11 ', byte(150), ' 20');

if Years_Nephrology_ = category1 then new_category='0-5';

else if Years_Nephrology_ = category2 then new_category='6-10';

else if Years_Nephrology_ = category3 then new_category='11-20';

else new_category='> 20';

run;

proc freq ;

tables new_category;

run;

jwsquillace
SAS Employee

The character printed has more to do with the font than anything.

Here is your sample that shows searching for both a long dash or a short dash. 

The results show that only the short dash appears in the text, but that may have been messed up by the editor.

/* test2.sas */

data abc;
  informat string $150.;
   input id string &;
pos_long = index(string, '96'x);       /* long dash */
pos_shrt = index(string,'2D'x);        /* short dash */
put string= / string $hex100. /;       /* display hex of first 50 characters in log */
  cards;
1 patient’s hemoglobin was less than or equal to 11 (units not provided). On an unknown date in May 2013
2 A former school cricket-coach was jailed for 15 months on Thursday for normal@range.
3 deleted stuff (5-6 c/sec) on right frontal derivations corresponding to the lesion site
4 The neurological examination at'admission showe'd a stuporous state with partial cluster seizures
5 The Singapore Armed Forces (S-A-F) will conduct military exercises in Seletar
;

Jan

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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