BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Haikuo
Onyx | Level 15

There you go! The key is applying strip() to remove blanks (mainly trailing blanks here):

data gafi_countries;

input gafi $20.;

cards;

bolivie

chypre

cyprus

équateur

equateur

éthiopie

ethiopie

indo

kenya

nigeria

nigéria

pakistan

sao

lanka

tanzanie

thai

tailand

turquie

viet

yemen

yémen

;

data sanction_countries;

input sanction $20.;

cards;

bélarus

belarus

chine

congo

rpdc

rdc

coree

corée

ivoire

cuba

érythrée

erythree

iran

iraq

irak

liban

lebanon

liberia

libéria

libye

lybie

lybia

myanmar

birmanie

sierra

somalie

somalia

soudan

sudan

syrie

zimbabwe

;

data mytest;

input objet $20.;

cards;

belarus acc

belarus refus

somalia acc

somalia refus

bolivie acc

bolivie refus

chypre acc

chypre refus

john

bob

;

data want;

  if _n_=1 then do;

  if 0 then set gafi_countries sanction_countries;

declare hash g(dataset:'gafi_countries');

g.definekey('gafi');

g.definedone();

declare hiter hig('g');

declare hash s(dataset:'sanction_countries');

s.definekey('sanction');

s.definedone();

declare hiter his('s');

end;

set mytest end=last;

  _temp=sum(count_gafi_acc,count_gafi_refus, count_sanction_acc, count_sanction_refus);

  do rc=hig.first() by 0 while (rc=0);

if find(objet, strip(gafi), 'i') and find(objet, 'acc','i') then count_gafi_acc+1;

  if find(objet, strip(gafi), 'i') and find(objet, 'refus','i') then count_gafi_refus+1;

  rc=hig.next();

end;

do rc=his.first() by 0 while (rc=0);

  if find(objet, strip(sanction), 'i') and find(objet, 'acc','i') then count_sanction_acc+1;

  if find(objet, strip(sanction), 'i') and find(objet, 'refus','i') then count_sanction_refus+1;

rc=his.next();

end;

if _temp >= sum(count_gafi_acc,count_gafi_refus, count_sanction_acc, count_sanction_refus) then count_person+1;

if last then output;

keep count_gafi_acc count_gafi_refus count_sanction_acc count_sanction_refus count_person;

run;

Haikuo

nicnad
Fluorite | Level 6

This works perfectly!

Thank you very much for your help and time.

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