BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
miajoe
Fluorite | Level 6

Hi smart people.

I have the following code:

data want;

set have;

if dep="1309825" then dep="" AND source_dep=. AND indexdate_dep=.;

run;

 

dep is a character value(it can contain letters) and is 11 characters long. SAS returns a 0 rather then a blank when i run this and I want a blank. I have tried:

 

if scan(dep,1,"1309825")=1 then dep="" AND ... and the rest, but the result is the same.

 

i Have also tried:

 

if lenght(dep)=7 and dep="1309825" then dep="" AND ... the rest, also with the same result.....

 

How can I make it return a blank and not a zero?

thank you

1 ACCEPTED SOLUTION

Accepted Solutions
miajoe
Fluorite | Level 6

I solved it. I just wanted to do to much in one go. When i split it up into three seperate if statements and replaced ="" with =" " it worked. So sorry to waste anyones time.

View solution in original post

2 REPLIES 2
miajoe
Fluorite | Level 6

I solved it. I just wanted to do to much in one go. When i split it up into three seperate if statements and replaced ="" with =" " it worked. So sorry to waste anyones time.

PaigeMiller
Diamond | Level 26

 

if dep="1309825" then dep="" AND source_dep=. AND indexdate_dep=.;

 

 

You want a blank, not a zero. Normally an assignment statement in a data step looks like this, where variable name is to the left of the equal sign and value assigned to the variable name is to the right of the equal sign. I'm surprised your code works at all, but I have never tried it. Perhaps you want (I'm guessing):

 

 

if dep='123456' then do;
    source_dep=. ;
    indexdate_dep=.;
    dep=" ";
end;

 

 

 

 

 

 

 

 

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 430 views
  • 0 likes
  • 2 in conversation