BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shasank
Quartz | Level 8

Hi Community,

 

I have trouble finding a solution for the below problem.

 

IDE1E2E3E4E5Int_startInt_end
1011.125
20011134
31110025
41111015
51000135

 

The above dataset has e1 to e5 array and Intervel_start and Intervel_end. The problem I have is to check the array of the Int_start and Int_end and capture the 0 or . in between the series of 1's .

 

IDE1E2E3E4E5Int_startInt_endDisenr
1011.125e4
20011134.
31110025e4
41111015e5
51000135e3

 

The logic of the Disenr variable is that if the array of Int_start and Int_end contains any value other than 1 then I would like to have that variable name in the disenr variable. 

 

Can you help?

 

Thank you for your time. 

 

Best,

SC.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20



data have;
infile cards expandtabs;
input ID	E1	E2	E3	E4	E5	Int_start	Int_end;
cards;
1	0	1	1	.	1	2	5
2	0	0	1	1	1	3	4
3	1	1	1	0	0	2	5
4	1	1	1	1	0	1	5
5	1	0	0	0	1	3	5
;

data want;
set have;
array t e:;
do _n_=int_start to int_end;
if t(_n_) ne 1 then do;
Disenr=vname(t(_n_));
leave;
end;
end;
run;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
/* UNTESTED CODE */

data want;
    set have;
    array e e1-e5;
    do i=int_start to int_end by 1;
        if e(i) ^= 1 then disenr=vname(e(i));
    end;
    drop i;
run;
--
Paige Miller
shasank
Quartz | Level 8
Thank you for your quick response. This helped me fix my problem.
novinosrin
Tourmaline | Level 20



data have;
infile cards expandtabs;
input ID	E1	E2	E3	E4	E5	Int_start	Int_end;
cards;
1	0	1	1	.	1	2	5
2	0	0	1	1	1	3	4
3	1	1	1	0	0	2	5
4	1	1	1	1	0	1	5
5	1	0	0	0	1	3	5
;

data want;
set have;
array t e:;
do _n_=int_start to int_end;
if t(_n_) ne 1 then do;
Disenr=vname(t(_n_));
leave;
end;
end;
run;

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 379 views
  • 1 like
  • 3 in conversation