BookmarkSubscribeRSS Feed
wrosario
Calcite | Level 5

Somehow hesitate to make a top Component 1 using the sas? I would like to do without having to use a proc.


example:


name         date                    value

joão          19/01/2014           35

marcos      20/01/2014          26

paulo         21/12/2013          10

roberto      10/12/2013          15

joão          11/12/2013          25

marcos      10/02/2014          15


Result


name         date                    value

joão          19/01/2014           35

paulo         21/12/2013          10

roberto      10/12/2013          15

marcos      10/02/2014          15


the top 1 would be the date, so would make an order by date and bring only the first record


Tks for all,

William

1 REPLY 1
Tom
Super User Tom
Super User

The normal way to do this in SAS is to use FIRST. processing.

data want ;

  set have ;

   by date ;

   if first.date ;

run;

You will need to sort the data first (or have it indexed).

Another work around is to use the NODUPKEY option on PROC SORT.

proc sort data=have out=want nodupkey ;

  by date;

run;

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!

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
  • 426 views
  • 0 likes
  • 2 in conversation