BookmarkSubscribeRSS Feed
brm
Calcite | Level 5 brm
Calcite | Level 5
Hi,

If One coloum is missing,then i want to delete all the records under that id.

How can i do this using query analyser in EG.Thanks in advance

brm
5 REPLIES 5
Patrick
Opal | Level 21
Hi

Assuming you're talking about the Query Builder and that "deleting" means you don't want such observations in the output then one way to go could be (EG 4.2):

1. Tab "Select Data":
Define a computed column. Step 1: "advanced expression", step 2: select your variable with missings, step 3: under Summary choose "NMISS"

2. Tab "Select Data":
Have your ID variable under "Summary groups".

3. Tab "Filter": Add the calculated variable to "Filter the summarized data". In a "basic filter" set the condition to "Equals to" with value "0"


This should result in SQL code which looks like:

PROC SQL;
CREATE TABLE SASUSER.QUERY_FOR_HAVE AS
SELECT t1.id,
t1.var,
/* nmiss_var */
(NMISS(t1.var)) AS nmiss_var
FROM WORK.HAVE AS t1
GROUP BY t1.id
HAVING (CALCULATED nmiss_var) = 0;
QUIT;


HTH
Patrick
reddy19
Calcite | Level 5
Patrick,

I did as you suggested...Here is the code generated

PROC SQL;
CREATE TABLE SASUSER.QUERY_FOR_BOOK13 AS
SELECT /* results */
(NMISS(t1.'Next Milestone Type'n)) AS results,
t1.DRC_CASE_ID,
t1.'Next Milestone Type'n
FROM SASUSER.BOOK13 AS t1
GROUP BY t1.DRC_CASE_ID
HAVING (CALCULATED results) = 0;
QUIT;

Getting below error in logs

ODS PDF(EGPDF) printed no output.
(This sometimes results from failing to place a RUN statement before the ODS PDF(EGPDF) CLOSE
statement.)

Please Tell me where i'm doing wrong.

Thanks,
reddy Message was edited by: reddy19
Patrick
Opal | Level 21
Hi reddy

The generated code as such looks o.k. to me.

If you don't get an output then one reason could be that variable 'Next Milestone Type'n has missing values for every single distinct value of by group variable "DRC_CASE_ID".

I'm hardly using PDF output so can't say anything about this one.

First thing I would try is running the script with another output destination to see if it's an ODS PDF issue or something else.

HTH
Patrick
brm
Calcite | Level 5 brm
Calcite | Level 5
Hi Patrick,

Below query is giving only the number of missing values

SELECT /* results */
(NMISS(t1.'Next Milestone Type'n)) AS results

So there is no way to exclude rows by id....because of that it is throwing error.

Thanks,
Bhavani.
Patrick
Opal | Level 21
Hi brm

Of course you can exclude rows by ID. The code I've posted was tested and returned the expected result.

The important part is the "group by" ID and "having clause" selecting only ID's where NMISS returned 0 (=no missings).

What reddy19 doesn't get is an output - but that can be caused by having missings for every by group. We have to wait for reddy19's next posting to know more.

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!

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
  • 5 replies
  • 1517 views
  • 0 likes
  • 3 in conversation