BookmarkSubscribeRSS Feed
SrikanthY
Calcite | Level 5

There are many patid's in my data sets. Each patid contains many rows. comment where the value is missing like in the posted one (attachment).

dataset structure:

2 lbnam's are grouped into one but some lbnames not.

output should be based on patid, visit and lbnam

sample data: and please find attachment for output sholud look like ..

 

PatIDVisitlbnamGroupValue
ID0011A121
ID0011B1 
ID0011C2 
ID0011D2 
ID0011E311
ID0011F322
ID0012A1 
ID0012C222
ID0012D211
ID0012E333
ID0012F311
ID0012G 2
ID0012H  

OutputFile.PNG
1 REPLY 1
art297
Opal | Level 21

I think that the following does what you want:

 

data want (drop=counter nmiss);
  do until (last.group);
    set have;
    by PatID Visit Group notsorted;
    if first.Group then do;
      counter=1;
      nmiss=0;
    end;
    else counter+1;
    if missing(value) then nmiss+1;
  end;
  do until (last.group);
    set have;
    by PatID Visit Group notsorted;
    if nmiss gt 0 and not missing(group)then do;
      if counter eq nmiss and counter gt 1 then comment='Y';
      else comment='N';
    end;
    output;
  end;
run;

Art, CEO, AnalystFinder.com

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 734 views
  • 0 likes
  • 2 in conversation