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

I have towns in a dataset flagged with "*" or nothing (" ")

I want to create a new variable called location where "*"= "north" and " "= "south"

When I do this code, it codes " " to "south" but not "*" to "north" 

data class4.water;
if flag="*" then location="north";
else if flag="" then location="south";
run; 

westbestern_0-1632964474471.png

Why is that happening? What can I do in my code to fix it? 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This step works as it should.  There is no SET statement, so no data is being brought in.  I hope you have a way of re-creating CLASS4.WATER, because running this program just wiped it out, replacing it with a single observation and no data other than what you are observing.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

This step works as it should.  There is no SET statement, so no data is being brought in.  I hope you have a way of re-creating CLASS4.WATER, because running this program just wiped it out, replacing it with a single observation and no data other than what you are observing.

tarheel13
Rhodochrosite | Level 12

need to post data so we can help. 

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 670 views
  • 3 likes
  • 3 in conversation