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

Hi there;

i need a help please:

my data is like this:

id          ne     dv                      

v 01     1       12/03/2008

v 01     1       12/03/2008

v 01     1       12/03/2008

v 01     1       12/03/2008

v 01     3       05/12/2012

v 01     3       05/12/2012

v 01     3       05/12/2012

v 02     1       31/01/2009

v 02     1       31/01/2009

v 02     1       31/01/2009

v 02     2       05/04/2011

v 02     2       05/04/2011

v 02     2       05/04/2011

v 02     2       05/04/2011

v 02     3       11/09/2003

v 02     3       11/09/2003

v 08     2       03/06/2014

v 08     2       03/06/2014

what i want:

 

id          ne     dv                    dv_1                   dv_2                 dv_3                 

v 01     1       12/03/2008       12/03/2008                 .                05/12/2012  

v 01     1       12/03/2008       12/03/2008                 .                05/12/2012

v 01     1       12/03/2008       12/03/2008                 .                05/12/2012

v 01     1       12/03/2008       12/03/2008                 .                05/12/2012

v 01     3       05/12/2012       12/03/2008                 .                05/12/2012

v 01     3       05/12/2012       12/03/2008                 .                05/12/2012

v 01     3       05/12/2012       12/03/2008                 .                05/12/2012

v 02     1       31/01/2009       31/01/2009         05/04/2011       11/09/2003

v 02     1       31/01/2009       31/01/2009         05/04/2011       11/09/2003

v 02     1       31/01/2009       31/01/2009         05/04/2011       11/09/2003

v 02     2       05/04/2011       31/01/2009         05/04/2011       11/09/2003

v 02     2       05/04/2011       31/01/2009         05/04/2011       11/09/2003

v 02     2       05/04/2011       31/01/2009         05/04/2011       11/09/2003

v 02     2       05/04/2011       31/01/2009         05/04/2011       11/09/2003

v 02     3       11/09/2003       31/01/2009         05/04/2011       11/09/2003

v 02     3       11/09/2003       31/01/2009         05/04/2011       11/09/2003

v 08     2       03/06/2014               .                  03/06/2014               .

v 08     2       03/06/2014               .                  03/06/2014               .

 

ne= measurement order
dv = date of a measurement

 

therefore, the table want should contain 3 new variables (dv_1 dv_2 and dv_3).
dv_1 contains the dates that correspond to ne= 1;
dv_2 contains the dates that correspond to ne= 2;
dv_3 contains the dates that correspond to ne= 3;

 

 

help me please.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try this:

 

proc sql;
create table u as select unique * from have order by id; 
quit;

proc transpose data=u out=v(drop=_name_) prefix=dv_;
by id;
id ne;
var dv;
run;

data want;
merge have v;
by id;
run; 
PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try this:

 

proc sql;
create table u as select unique * from have order by id; 
quit;

proc transpose data=u out=v(drop=_name_) prefix=dv_;
by id;
id ne;
var dv;
run;

data want;
merge have v;
by id;
run; 
PG
soumri
Quartz | Level 8

dear 

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
  • 2 replies
  • 775 views
  • 1 like
  • 2 in conversation