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

Hi 

 

I'm looking for code that can keep records who appeared once in my dataset FDFD,  and one appearance for records that repeated more than one time. 

 my code will be for these variables A, B, C, P, PEAKYIELD, and TmDAYS. 

 

Regards

 

A	                        B	                 C	                P	            peakYield	tmdays
45.50222622	0.155650915	0.134354472	2.319707636	39.84559673	
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376

37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

What do you want as output?

 

You're either looking at PROC SORT, which can remove duplicates or unique records as desired.

 

If you're looking to flag the records you need to use BY group processing, this post has an example with multiple by groups. 
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/

 

Please include any code you've tried so far, so we can provide more direction or indicate what you need to change.

 


@Barkamih wrote:

Hi 

 

I'm looking for that can keep records that appeared once,  and appearance for records that repeated more than one time. 

 my code will be for these variables A, B, C, P, PEAKYIELD ANDTNDAYS. 

 

Regards

 

A	                        B	                 C	                P	            peakYield	tmdays
45.50222622	0.155650915	0.134354472	2.319707636	39.84559673	
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376

37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767

 

View solution in original post

4 REPLIES 4
Reeza
Super User

What do you want as output?

 

You're either looking at PROC SORT, which can remove duplicates or unique records as desired.

 

If you're looking to flag the records you need to use BY group processing, this post has an example with multiple by groups. 
https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/

 

Please include any code you've tried so far, so we can provide more direction or indicate what you need to change.

 


@Barkamih wrote:

Hi 

 

I'm looking for that can keep records that appeared once,  and appearance for records that repeated more than one time. 

 my code will be for these variables A, B, C, P, PEAKYIELD ANDTNDAYS. 

 

Regards

 

A	                        B	                 C	                P	            peakYield	tmdays
45.50222622	0.155650915	0.134354472	2.319707636	39.84559673	
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376
22.52354346	0.518806327	0.175347086	2.644223471	23.5361343	2.958739376

37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767
37.70843347	0.228103848	0.124659053	2.557124486	34.45329026	1.829821767

 

Barkamih
Pyrite | Level 9

I did this code but  this one has deleted records that app

Data  merged;
 set merged;
 by A B C P PEAKYIELD TMDAYS  notsorted;
 if not first.A then A=.;
 if not first.B then B=.;
 if not first.C then C=.;
 if not first.P then P=.;
 if not first.LOGTM then TMDAYS=.;
 if not first.PEAKYIELD then PEAKYIELD=.;
run;

eared only one time 

Reeza
Super User

What do you want as output?

Barkamih
Pyrite | Level 9
thank you so much
I got my code, I was having a simple mistake in my first code
regards

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 631 views
  • 0 likes
  • 2 in conversation