Desktop productivity for business analysts and programmers

Setting a flag if data value present

Reply
Occasional Contributor
Posts: 18

Setting a flag if data value present

[ Edited ]

If any Lead number is Present in the Given data it should appear as installed=1 

 

How to Solve this in Proc Sql ?

 

Ex :

 

Lead Number      Installed

2121221               1

2212154               1

 

SAS Moderator
Posts: 55

Re: Regarding SAS [how to improve your question]

Posted in reply to saikiran_nemani

Hello @saikiran_nemani,


Your question requires more details before experts can help. Can you revise your question to include more information? 

 

Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
    use_buttons.png
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.

 

edit_post.png

SAS experts are eager to help -- help them by providing as much detail as you can.

 

This prewritten response was triggered for you by fellow SAS Support Communities member @KurtBremser

.
Respected Advisor
Posts: 2,825

Re: Regarding SAS

[ Edited ]
Posted in reply to saikiran_nemani

Data step solution

data want;
    set have;
    if not missing(lead_number) then installed=1;
run;

And yes, a more meaningful title and more information is always appreciated and helpful.

--
Paige Miller
Super User
Posts: 6,632

Re: Regarding SAS

Posted in reply to saikiran_nemani

To do that in SQL, use a CASE clause within the SELECT statement.

 

Unfortunately, the syntax depends on whether LeadNumber is character or numeric, and you haven't yet told us that information.

Super User
Super User
Posts: 7,933

Re: Regarding SAS

Posted in reply to saikiran_nemani

What value should the new INSTALLED variable have when LEADNUMBER is missing?

It is probably easiest in SAS to just let SAS create the new variable as a boolean number where 1 is true and 0 is false.

For example you could use the SAS function MISSING() to test if LEADNUMBER is missing.  And use the NOT operator to take the complement of the result.

proc sql;
select
    leadNumber
  , not missing(leadNumber) as Installed
  from have
;
quit;
Occasional Contributor
Posts: 18

Re: Regarding SAS

Suppose these are the Lead numbers and How do we Create a variable called Install with the Value 1 for each lead number

Data Type : NUMERIC

42129203

43899661
43947460
45396478
45439343
45566313
45599714

Respected Advisor
Posts: 2,825

Re: Regarding SAS

Posted in reply to saikiran_nemani

Please read the replies already provided above.

--
Paige Miller
Ask a Question
Discussion stats
  • 6 replies
  • 193 views
  • 2 likes
  • 5 in conversation