BookmarkSubscribeRSS Feed
pankak
Calcite | Level 5

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






1 REPLY 1
naveen20jan
Obsidian | Level 7

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1 reply
  • 711 views
  • 0 likes
  • 2 in conversation