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: 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
  • 2 replies
  • 517 views
  • 0 likes
  • 2 in conversation