BookmarkSubscribeRSS Feed
Miracle
Barite | Level 11

Dear Everyone,

May I please ask how do we get the last column, 'flag' given my input data containing id, date, vis and site?
I would like to be able to flag the most recent non-missing var from a visit given the date by site for patients.

Your help is very much appreciated.

id	date	vis	site	var	flag
1	01-Jan-2020	1	1		1
1	02-Feb-2020	2	1	10	1
1	03-Mar-2020	3	1	11	0
1	10-Mar-2020	3	1	12	1
1	05-Apr-2020	4	1	11	1
1	06-May-2020	5	1	9	1
1	07-Jun-2020	6	1	.	0
1	06-Jun-2020	6	1	13	1
1	09-Aug-2020	8	1	10	1
1	01-Jan-2020	1	2	9	1
1	02-Feb-2020	2	2	7	1
1	03-Mar-2020	3	2	5	1
1	10-Mar-2020	3	2	7	1
1	05-Apr-2020	4	2	8	1
1	06-May-2020	5	2	.	1
1	07-Jun-2020	6	2	7	1
1	25-Aug-2020	8	2	.	0
1	09-Aug-2020	8	2	10	1
2	01-Jan-2020	1	1	4	1
2	02-Feb-2020	2	1	10	1
2	03-Mar-2020	3	1	11	0
2	10-Mar-2020	3	1	12	1
2	05-Apr-2020	4	1	11	1
2	06-May-2020	5	1	9	1
2	07-Jun-2020	6	1	9	1
2	25-Jun-2020	7	1	13	1
2	09-Aug-2020	8	1	10	1
2	01-Jan-2020	1	2	9	1
2	02-Feb-2020	2	2	7	1
2	03-Mar-2020	3	2	5	0
2	10-Mar-2020	3	2	7	1
2	05-Apr-2020	4	2	8	1
2	06-May-2020	5	2	6	1
2	07-Jun-2020	6	2	7	1
2	31-Aug-2020	8	2	20	1
2	09-Aug-2020	8	2	10	0

 

4 REPLIES 4
Kurt_Bremser
Super User

With id = 1, site = 1, and vis = 3, you flag both observations as 1, but with id = 2, site = 2, vis = 8, you only flag the later as 1; what is the difference here?

Miracle
Barite | Level 11

Thanks @Kurt_Bremser for pointing out.
Post is now corrected.

Miracle
Barite | Level 11

Thanks @Kurt_Bremser  for trying to help 😊

I managed to get it done correctly by following this post here instead 

https://communities.sas.com/t5/SAS-Data-Management/create-a-flag-for-first-non-zero-observation-by-g...

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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