I have a table below and I want to create a table where the first 'ID' is 'test'' =1. If the first 'ID' isn't 'test' =1 then to have it in a separate column.
ID
date
test
1
6/7/18
8/12/28
2
5/4/18
3
6/20/18
10/4/18
4
5/8/18
7/23/18
5
3/9/18
7/4/18
11/20/18
I want the output to look like this
Test1
Test2
You missed to sign the first of ID=4.
Assuming data is sorted by ID then:
data want; set have; by ID; if first.id then test=1; else test=.; run; options missing=' ';
View solution in original post
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 16. Read more here about why you should contribute and what is in it for you!
Submit your idea!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.