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

Hello ,

I want to create data "B" from data "A". That is , I want to keep only data with at least two time points;

 

Data a,
Input id timepoint;
Cards;
001     1
001     2
001     3
002    1
003    1
003    2
004    1
005    1
;
 
Run;

 

 

 Data "B" is created from data "A". id 002 , 004 and 005 are dropped because they are just one time points.

 

 

Data B;
Input id timepoint;
Cards;
 
001     1
001     2
001     3
 
003    1
003    2
;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

You can use the NOUNIQUEKEY option on PROC SORT.

 

proc sort
     data = sashelp.adomsg
          out = duplicates
          uniqueout = singles
          nouniquekey;
     by msgid;
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

proc sql;

create table b as

select *

from a

group by id

having count(id)>1;

quit;

desireatem
Pyrite | Level 9

Thanks

Reeza
Super User

You can use the NOUNIQUEKEY option on PROC SORT.

 

proc sort
     data = sashelp.adomsg
          out = duplicates
          uniqueout = singles
          nouniquekey;
     by msgid;
run;
Jagadishkatam
Amethyst | Level 16

With datastep as well

 


data a2;
do until(last.id);
set a;
by id timepoint;
if first.id then count=1;
else count+1;
end;
do until(last.id);
set a;
by id timepoint;
if count>1 then output ;
end;
run;

 
Thanks,
Jag

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 2969 views
  • 2 likes
  • 4 in conversation