BookmarkSubscribeRSS Feed
Sassybanana
Fluorite | Level 6

Data tagline1;

Set tagline;

 

If var1 = -3 then varnew = .;
run;
When attempting to run this it does not identify -3 as sas missing includes it within the output.

5 REPLIES 5
Patrick
Opal | Level 21

This code will do as you tell it to do. What exactly is not working as you'd expect? 

 

Assuming you create varnew in your data step and it doesn't already exist in table tagline:

You never assign a value to varnew so it will always be missing whether the condition is now true or not.

Sassybanana
Fluorite | Level 6
Here is the code. When a proc freq is ran the -3 values are still included within the new variable 1.
Kurt_Bremser
Super User

Please post code by copy/pasting it into a code box. No need to create nigh-unreadable pictures.

A code box is opened with the "little running man" button right next to the one indicated:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

The indicated button is for logs.

Patrick
Opal | Level 21

In your code whenever tagline = -3 is true then tagline <40 will be true as well. And because this is not an IF/ELSE construct the last test wins and tagline_new will be set to 1 for cases where tagline = -3.

 

Patrick_0-1634625629956.png

 

Astounding
PROC Star
Your program does not change VAR1. So -3 would remain in the data. Did you intend to code:

if var1 = -3 then var1 = .;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 941 views
  • 0 likes
  • 4 in conversation