Help using Base SAS procedures

Help with grouping

Accepted Solution Solved
Occasional Contributor
Posts: 5
Accepted Solution

Help with grouping

I have a table with 54 variables. I need to group the Id in a way that it meets the conditions specified below in bold. I would appreciate if some one can give me a hint. Thanks


ID  MARRY07X   TTLP07X   SSIDIS07   FAMINC07   AGE07X   CHADDx=1   ASATAK53 =1   OR AIDHLP53 =1      OR WLKLIM53 =1        OR SOCLIM53 =1 OR       COGLIM31=1 OR        COGLIM53=1 OR         BLIND42= 1        OR DEAF42 = 1      OR ADDAYA42 =1

OR ADCLIM42 =1        OR ADPAIN42 in (4,5)         OR ADSOCA42 in (1,2)         OR DSKIDN53=1       OR DSEYPR53=1            OR ARTHDX=1          OR JTPAIN53=1        OR UNABLE53=1          OR ACTLIM31=1         OR ACTLIM53=1

OR ADMWLM42 in (1,2)    OR ADPWLM42 in (1,2)         OR BENDIF31 in (3,4)            OR BENDIF53 in (3,4)        OR FNGRDF31 in (3,4)           OR FNGRDF53 in (3,4)            OR JTPAIN31=1           OR LFTDIF31 in (3,4)

OR LFTDIF53 in (3,4)            OR MILDIF31 in (3,4)          OR MILDIF53 in (3,4)         OR RCHDIF31 in (3,4)         OR RCHDIF53 in (3,4)           OR STNDIF31 in (3,4)           OR STNDIF53 in (3,4)           OR STPDIF31 in (3,4,5)

OR STPDIF53 in (3,4,5)        OR UNABLE31=1         OR WLKDIF31 in (3,4)           OR WLKDIF53 in (3,4)         OR WLKLIM31=1         OR WRKLIM31=1 OR         WRKLIM53=1        OR BMINDX53 GE 30

Accepted Solutions
‎07-27-2012 12:01 PM
Posts: 7,362

Re: Help with grouping

Maybe it is just me, or that it is Friday, but I don't understand your question.

View solution in original post

All Replies
‎07-27-2012 12:01 PM
Posts: 7,362

Re: Help with grouping

Maybe it is just me, or that it is Friday, but I don't understand your question.

Occasional Contributor
Posts: 5

Re: Help with grouping

And may it it is me or Friday, I received a message that says you need the approval. If it is the case you have my approval for please send me email if still unclear of my question.

Thank yoju

Posts: 7,362

Re: Help with grouping


You received that message because you clicked on adding me as a connection.  Just reply to this post and be more specific about the variables you have and what you want to accomplish.  It wasn't at all clear from your original post.

Occasional Contributor
Posts: 5

Re: Help with grouping

I have this data file with 54 variables. There is an ID that I used for grouping the data. It is an unduplicated file though. I need to create a data file that includes all the ids that meet the specifications of the conditions. The one that were bold in the original email.

Like all the ids that have the condition of CHDDX =1 and all the ids that meet the condition of ADPAIN in (4,5), and so on. my original data file includes all the individuals between the ages of 18 and 64 who falls in the category of poverty line of 125% to 250%. Then I created the file that included all the conditions. I used "or" operator so that I will all all the individuals that meet one or more of the conditions. Here is some example of my file.

ID                Age    CHDDX          ASATAK53          ADPAIN

60127019     59        2                           -4                 1             

60129016     53        1                           2                 -1

60129023     51       -8                           1                  2

60129030    25         4                          5                  -1

Now I need to includes all the IDS athat for CHDDX =1 and for ASATAK=2 and for ADPAIN = -1.

Thank you.

Super Contributor
Posts: 1,636

Re: Help with grouping

proc sql;

  create table your_new_dateset as

    select * from yourdataset

       where CHDDX =1 and  ASATAK=2 and ADPAIN = -1;


Posts: 7,362

Re: Help with grouping

data want;

  set have;

  if CHADDx=1

   or ASATAK53 =1

   or AIDHLP53 =1

   or WLKLIM53 =1

   or SOCLIM53 =1

   or COGLIM31=1

   or COGLIM53=1

   or BLIND42= 1

   or DEAF42 = 1

   or ADDAYA42 =1

   or ADCLIM42 =1

   or ADPAIN42 in (4,5)

   or ADSOCA42 in (1,2)

   or DSKIDN53=1

   or DSEYPR53=1

   or ARTHDX=1

   or JTPAIN53=1

   or UNABLE53=1

   or ACTLIM31=1

   or ACTLIM53=1

   or ADMWLM42 in (1,2)

   or ADPWLM42 in (1,2)

   or BENDIF31 in (3,4)

   or BENDIF53 in (3,4)

   or FNGRDF31 in (3,4)

   or FNGRDF53 in (3,4)

   or JTPAIN31=1

   or LFTDIF31 in (3,4)

   or LFTDIF53 in (3,4)

   or MILDIF31 in (3,4)

   or MILDIF53 in (3,4)

   or RCHDIF31 in (3,4)

   or RCHDIF53 in (3,4)

   or STNDIF31 in (3,4)

   or STNDIF53 in (3,4)

   or STPDIF31 in (3,4,5)

   or STPDIF53 in (3,4,5)

   or UNABLE31=1

   or WLKDIF31 in (3,4)

   or WLKDIF53 in (3,4)

   or WLKLIM31=1

   or WRKLIM31=1

   or WRKLIM53=1

   or BMINDX53 GE 30;


Super Contributor
Posts: 282

Re: Help with grouping


I'm not sure I understand the requirements; were you looking for something like:

proc sql noprint;

  create table want as

  select *

  from have

  where <your-conditions>

  order by id



I did notice your condition does not have an "and" or an "or" between the first two tests of equality "CHADDx=1   ASATAK53 =1".



☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 4 in conversation