Learning SAS? Welcome to the exclusive online community for all SAS learners.

Need help with trying to make a Variable Binary.

Reply
Occasional Contributor
Posts: 7

Need help with trying to make a Variable Binary.

I have imported a document from excel. In excel I created a variable that is binary. When I look at the variable in stat explore it says it has 3 levels. 1,2 and a dot. I dont know how to fix this or change it and my project is due by midnight.

Super User
Posts: 8,215

Re: Need help with trying to make a Variable Binary.

Posted in reply to victorgarza350

You'd have to explain what you meant when you said "In excel I created a variable that is binary."

 

What you have is a variable that either has a 1 or a 2, or is missing (which is represented by a period).

 

Art, CEO, AnalystFinder.com

 

Occasional Contributor
Posts: 7

Re: Need help with trying to make a Variable Binary.

I need to make the variable own/rent into a binary interval. Please help

Super User
Posts: 13,924

Re: Need help with trying to make a Variable Binary.

Posted in reply to victorgarza350

The . in SAS is the default appearance of a missing value. That would mean that one or more of your records either had nothing entered for any records with the dot or that something considered other than the numeric values of 1 and 2 were in the cell.

 

So what would you like the value of the missing to be?

 

I would also suggest that for binary variables that you code them as 1 for "yes" or "true" and 0 for "no" or "false".

One reason is that in program logic SAS considers 0 to be "false". So in a conditional statement you can use:

If var then do <>.

the "do" part of the code would not execute for 0 values of the variable named var.

Another reason is when working with summary statistics. A SUM of the variable would give the number of "yes" or "true" values and the mean would give a the decimal version of a percentage.

There are also a number of analysis procedures that work much better with 0/1 coded results.

 

Occasional Contributor
Posts: 7

Re: Need help with trying to make a Variable Binary.

Can you help me here i the excel doc.

Im trying to make the Own/Rent Variable into a binary. Simple 1 or 0

Super User
Posts: 8,215

Re: Need help with trying to make a Variable Binary.

Posted in reply to victorgarza350

Own_or_rent has values of 1,2,3,4,5 and 9. How do you want to convert that to binary? You may know what those values mean .. we don't!

 

Art, CEO, AnalystFinder.com

 

Occasional Contributor
Posts: 7

Re: Need help with trying to make a Variable Binary.

Just need to make it where 1 in own and all the other numbers will be the other variable.

1 = own

2,3,4,5,9 will = 2 = rent

does that make sense

Super User
Posts: 8,215

Re: Need help with trying to make a Variable Binary.

Posted in reply to victorgarza350

If you really want to make it binary, I'd change the variable to Own and make the values 1=yes 0=no.

 

i.e., within a datastep:

 

if own_or_rent eq 1 then own=1;
else own=0;

Art, CEO, AnalystFinder.com

 

Occasional Contributor
Posts: 7

Re: Need help with trying to make a Variable Binary.

How can I do it in excel?

Super User
Posts: 8,215

Re: Need help with trying to make a Variable Binary.

Posted in reply to victorgarza350

We only answer SAS questions here. Ask your question on either one of the Excel forums or stackoverflow.

 

Art, CEO, AnalystFinder.com

 

Ask a Question
Discussion stats
  • 9 replies
  • 212 views
  • 0 likes
  • 3 in conversation