BookmarkSubscribeRSS Feed
aiste
Fluorite | Level 6

Hello everyone,

 

I hope you'll help me to figure out the fastest way to do the following:

I have a big data set with many columns. I would like to apply the idea such as 'for each column 'user' and for each column 'ID', if the column 'Position' is negative then delete it IF AND ONLY IF it's the first entry according to each 'user' and each 'ID' '.

 

Basically, I want to delete every first entry for each 'user'  AND for each 'ID' which have 'position' lower than 0. 

 

I attach a data sample for user=56 and one only ID. in this case, since it's sorted for proc sort data=trial; by user ID day; run; AND the first position is negative AND transtype='S', I would want to delete it.  But I am not sure how to do it in the best way for when I have many users and many different IDs.

 

Thank you in advance for your suggestions!

 

2 REPLIES 2
mkeintz
PROC Star

@aiste :

 

I do have a suggestion:  show a sample of data, in the form of a sas data step, and then show, in the fomr of a sas data step, what the results should look like.   There are some might smart people on this forum, but don't assume they are mind readers.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
aiste
Fluorite | Level 6
thank you, I added an example.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 542 views
  • 0 likes
  • 2 in conversation