I have a transposed dataset in the following manner:
id_acc info0 info1 info2 info3 info4 info5 info6 info7 info8 info9 info10 info11 info12 info13 info14 info15 info16 info17 info18 info19 info20 info21
111 AAA AAA AAA D1A D2A D3A AAA AAA AAA AAA AAA D1A D2A D3A LEP LWP LEP LWP LEP LWP LEP LEP
222 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
223 AAA AAA AAA D1A D2A AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA D1A D2A D3A ISP LEP
224 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
225 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
226 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
227 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
228 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
229 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
231 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
232 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
233 D1A D2A AAA D1A AAA AAA D1A D2A D1D D2D D3D D4D D5A D6D AAA AAA AAA ISP LEP LWP LEP LEP
234 D1A D2A AAA D1A AAA AAA D1A D2A D1D AAA AAA AAA AAA AAA AAA AAA ISP LEP LWP LEP LEP ISP
Now what kind of flag i need is mentioned as follows:
1. when it was in (D1A or D1D ) and not in other info to (D3A or D6D) as (dstart and dend).value will be 1.
2 when it was in (D1A or D1D )and not in other info to (LEP or ISP orLWP) as (dstart and Lend) value will be 1.
3.when it was in AAA and not in other info to (ISP,LEPor LWP) as (astart and lend) and value will be 1
There might be more scenarios but i have to focus on three one.
There are multiple unique id and more info apart from that.
So please show me some global method so that i can apply on whole dataset.
Thanks,
Pankaj
Hi Pankaj ,
i can think of a vague approach you can modify it accordingly ;
we will use an array and multiple do loop for this ;
part of code is as below ;
array info (*) info_0 -- info_21 ;
%do i = 0 to until (info_&i = "DIA") ;
x= info_&i ;
%end ;
%do i = x to until info_&i in (D6D , D3A) ;
dstart = 1 ;
dend = 1 ;
y = info&i ;
end;
and you can add loops as per requirement
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.