BookmarkSubscribeRSS Feed
saikiran_nemani
Obsidian | Level 7

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

 

6 REPLIES 6
Community_Guide
SAS Moderator

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 @Kurt_Bremser

.
PaigeMiller
Diamond | Level 26

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
Astounding
PROC Star

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.

Tom
Super User Tom
Super User

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;
saikiran_nemani
Obsidian | Level 7

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

PaigeMiller
Diamond | Level 26

Please read the replies already provided above.

--
Paige Miller

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 1229 views
  • 2 likes
  • 5 in conversation