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

Dear All,

 

I am using SAS data management studio 9.4 version, it is frontend interface where in there are only options of drag & drop and also to write few expressions.

 

I am in this sitution where the data is repeated and i need to eliminate them from the file. I have tried using clusters by grouping the primary key but getting stuck in the next condition. Please suggest me the appropriate solution, provided below the data.

 

Required : if roll no = 123A then remove the roll no, i.e. 0012 and 0064 has 123A area so the whole 0012 and 0064 should be removed from the data. The output should only consist of 12345 roll no

 

Input
Roll No Name Area
0012 KKKKK 123A
0012 KKKKK 3333
0012 KKKKK 7869
0012 KKKKK 7777
0012 KKKKK 913B
12345 LLLLL 7869
12345 LLLLL 123A
12345 LLLLL 3333
0064 MMMM 7869
0064 MMMM 7869
0064 MMMM 3333
0064 MMMM 123A
0064 MMMM 7869
0064 MMMM 6666
0064 MMMM 913B

 

Output
Roll No Name Area
12345 LLLLL 7869
12345 LLLLL 123A
12345 LLLLL 3333

 

Regards,
Shaheen 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shah
Obsidian | Level 7

Dear All,

 

I found solution for this, used sql lookup to get the output. Thank you all.

 

Regards,

Shaheen

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20

I'm not a specialist in DM Studio, but I think you need to clarify the requirement.

First, what makes you want to keep the 12345 Roll no records? What so specific about them?

Second, once you filtered out what you want, how do you intend to use this? Assuming you are building some kind of match code that can be applied to production data streams...?

Data never sleeps
Patrick
Opal | Level 21

@Shah

I'm not a DM Studio expert but looking into the documentation tells me that you've got the full SQL syntax at your command (i.e. SQL Query Node).

 

This should allow you to define logic similar to below done with "normal" SAS.

data have;
  input Roll_No $ Name $ Area $;
  datalines;
0012 KKKKK 123A
0012 KKKKK 3333
0012 KKKKK 7869
0012 KKKKK 7777
0012 KKKKK 913B
12345 LLLLL 7869
12345 LLLLL 123B
12345 LLLLL 3333
0064 MMMM 7869
0064 MMMM 7869
0064 MMMM 3333
0064 MMMM 123A
0064 MMMM 7869
0064 MMMM 6666
0064 MMMM 913B
;
run;

proc sql;
  create table want1 as
    select o.*
      from 
        have as o
      where not exists
        (select * from have i where i.area='123A' and i.roll_no=o.roll_no)
  ;
quit;

 

N.B: I've been a bit "struggling" with the logic and expected output you've posted and had to work on assumptions.

 

Above code returns all records with roll_no values where area is never 123A

In the sample data you've posted above condition would never be true so I've also modified your sample data for roll_no=12345

 

 

Shah
Obsidian | Level 7

Dear All,

 

I found solution for this, used sql lookup to get the output. Thank you all.

 

Regards,

Shaheen

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 992 views
  • 2 likes
  • 3 in conversation