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 = .;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 660 views
  • 0 likes
  • 4 in conversation