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

Hi guys,

Can someone help me to change the dataset according to the following?

 

 

Thank you.

 

 

Khalid

Slide1.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Nothing wrong with grouping them together. e.g.:

 

data want;
  set have;
  if v1=v2=v3=8 then call missing(of v1-v3);
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

7 REPLIES 7
Reeza
Super User

Whats the rule? All 8s or all the same value? What if you have two the same value and one is missing.

 

You can use MIN/MAX logic - if the min=max then the values are the same and you can use CALL MISSING to set variables to missing. 

 

Useful functions:

 

N - returns number of non missing

NMISS - returns the number of missing

MIN - returns minimum value

MAX - returns max value

CALL MISSING() - sets variables designated to as missing - doesn't matter if they're character or numeric.

 

 

PS. Post data not in images but at least as text, ideally as a data step. We can't write code based on an image so that would mean typing out your dataset. 

 

 

 

art297
Opal | Level 21

or just use something like:

 

data want;
  set have;
  array vars(*) v1-v3;
  if v1=v2=v3 then call missing(of vars(*));
run;

Art, CEO, AnalystFinder.com

 

khalidamin
Obsidian | Level 7
I want 'if v1=v2=v3=8 THEN 'v1=v2=v3=missing'.
khalidamin
Obsidian | Level 7

Thank you for your comments. I want to consider 8s as missing when they are in all variables. For example, if v1=v2=v3=8, then

v1=v2=v3=missing. @Reeza

Reeza
Super User

If v1=8 and v2=8 and v3 =8 then call missing(v1, v2, v3);

art297
Opal | Level 21

Nothing wrong with grouping them together. e.g.:

 

data want;
  set have;
  if v1=v2=v3=8 then call missing(of v1-v3);
run;

Art, CEO, AnalystFinder.com

 

khalidamin
Obsidian | Level 7
Awesome! Thank you @art297 🙂

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 20531 views
  • 3 likes
  • 3 in conversation