BookmarkSubscribeRSS Feed
lsw2920
Calcite | Level 5

I misuploaded it to other forum so I moved my question to here.

 

I am trying to program a simple code.


Original data:
TableA

ID   |    Date      | Type

1      20111111       A

2      20081014     C

3      20051126      A

...

100  20160421      B

 

From this original data, I want to pick up dates by Type.

Like following

 

Result (only picking up A & B)

ID   | DateofA     | DateofB

1     | 20111111  |

2     |                  |

3     | 20051126 |

...

100 |                  | 20160421

 

 

Are there anyone know how to program this?

 

Thank you in advance.

 

2 REPLIES 2
r_behata
Barite | Level 11

Is this what you are looking for  ?

 

data have;
input ID $ Date Type $;
datalines;
1 20111111 A
2 20081014 C
3 20051126 A
100 20160421 B
;
run;


proc sort data=have;
by id;
where type in ('A','B');
run;

Proc transpose data=have out=want(drop=_name_ ) prefix=dateof;
id type;
by id;
var date;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 649 views
  • 0 likes
  • 3 in conversation