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

hi all -

i have two variable 'a' and 'b'. 'a' has 33092 and 'b' has 35760 observation. some observation are matching in both and some are not.

i wants to create new variable 'c' which has same observation from both 'a' and 'b' (i mean matching from both variable 'a' and 'b') variables and

new variable 'd' which has observation from 'b' but doesn't has observation from 'a'

can anyone help please?

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You mean something like this?

data want;

set have;

if a = b then c = a;

else d = b;

run;

PG

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

You mean something like this?

data want;

set have;

if a = b then c = a;

else d = b;

run;

PG

PG
sas_9
Obsidian | Level 7

thanks PG!

sas_9
Obsidian | Level 7

Hi PG i have one more q if you can answer me...,.

have same 'a' and 'b' variable

a                    b

01001      01001

01002      01002

01004      .

01005      01005

01021      .

in outout i want only 01004,01021 - how can i get that...

Thank You...

PGStats
Opal | Level 21

If I understand your request, you can get the list of cases where b is missing as a dataset with:

data want;

set have; where b is missing;

keep a;

run;

If you just want to print the cases:

proc print data=have(where=(b is missing)); var a; run;

PG

PG
sas_9
Obsidian | Level 7

Thanks you so much for your help PG!

Appreciate your 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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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