My dear friends,
How can I mark an intervall? I like to to mark the first Top_layer and the first Bottom_layer to be marked. I like to show the inside of a layer by marking it to number one. Please look at my dataset:
Please notice that the LAYER_NAME is changing (from A to C)
A Top_layer never starts at one LAYER_NAME and ends in another LAYER_NAME. All top layers and bottom layers belong to a specific layer_name
LAYER_NAME | DEPTH | Top_layer | Bottom_layer | MARK |
A | 0 | . | . | |
A | 0,5 | . | . | |
A | 1 | . | . | |
A | 1,5 | 1,5 | . | 1 |
A | 2 | . | . | 1 |
A | 2,5 | . | . | 1 |
A | 3 | . | . | 1 |
A | 3,5 | . | . | 1 |
A | 4 | . | . | 1 |
A | 4,5 | . | . | 1 |
A | 5 | . | . | 1 |
A | 5,5 | . | 5,5 | 1 |
A | 6 | . | . | |
A | 6,5 | . | . | |
A | 7 | . | . | |
A | 7,5 | 7,5 | . | 1 |
A | 8 | . | . | 1 |
A | 8,5 | . | . | 1 |
A | 9 | . | 9 | 1 |
A | 9,5 | . | . | |
A | 10 | . | . | |
B | 0 | . | . | |
B | 0,5 | 0,5 | . | 1 |
B | 1 | . | . | 1 |
B | 1,5 | . | . | 1 |
B | 2 | . | 2,5 | 1 |
B | 2,5 | . | . | |
B | 3 | . | . | |
B | 3,5 | . | . | |
B | 4 | . | . | |
B | 4,5 | . | . | |
C | 0 | . | . | |
C | 0,5 | . | . | |
C | 1 | 1 | . | 1 |
C | 1,5 | . | . | 1 |
C | 2 | . | . | 1 |
C | 2,5 | . | . | 1 |
C | 3 | . | 3 | 1 |
C | 3,5 | . | . | |
C | 4 | . | . | |
C | 4,5 | . | . | |
C | 5 | 5 | . | 1 |
C | 5,5 | . | . | 1 |
C | 6 | . | 6 | 1 |
C | 6,5 | . | . | . |
C | 7 | . | . | . |
C | 7,5 | 7,5 | . | 1 |
C | 8 | . | . | 1 |
C | 8,5 | . | 8,5 | 1 |
C | 9 | . | . | |
C | 9,5 | . | . | |
C | 10 | . | . |
I would be very grateful if you help me with this
Thank you very much in advance
Here is one way
data have;
input LAYER_NAME $1 MD_FT 3-5 Top_layer 7-9 Bottom_layer 11-13;
infile datalines dlm='|';
datalines;
A|0 |. |.
A|0.5|. |.
A|1 |. |.
A|1.5|1.5|.
A|2 |. |.
A|2.5|. |.
A|3 |. |.
A|3.5|. |.
A|4 |. |.
A|4.5|. |.
A|5 |. |.
A|5.5|. |5.5
A|6 |. |.
A|6.5|. |.
A|7 |. |.
A|7.5|7.5|.
A|8 |. |.
A|8.5|. |.
A|9 |. |9
A|9.5|. |.
A|10 |. |.
B|0 |. |.
B|0.5|0.5|.
B|1 |. |.
B|1.5|. |.
B|2 |. |2.5
B|2.5|. |.
B|3 |. |.
B|3.5|. |.
B|4 |. |.
B|4.5|. |.
C|0 |. |.
C|0.5|. |.
C|1 |1 |.
C|1.5|. |.
C|2 |. |.
C|2.5|. |.
C|3 |. |3
C|3.5|. |.
C|4 |. |.
C|4.5|. |.
C|5 |5 |.
C|5.5|. |.
C|6 |. |6
C|6.5|. |.
C|7 |. |.
C|7.5|7.5|.
C|8 |. |.
C|8.5|. |8.5
C|9 |. |.
C|9.5|. |.
C|10 |. |.
;
data want;
set have;
if Top_layer ne . then mark=1;
if Bottom_layer ne . then do;
output;
mark=.;
return;
end;
output;
retain mark;
run;
Result:
LAYER_NAME DEPTH Top_layer Bottom_layer MARK A 0 . . . A 0.5 . . . A 1 . . . A 1.5 1.5 . 1 A 2 . . 1 A 2.5 . . 1 A 3 . . 1 A 3.5 . . 1 A 4 . . 1 A 4.5 . . 1 A 5 . . 1 A 5.5 . 5.5 1 A 6 . . . A 6.5 . . . A 7 . . . A 7.5 7.5 . 1 A 8 . . 1 A 8.5 . . 1 A 9 . 9 1 A 9.5 . . . A 10 . . . B 0 . . . B 0.5 0.5 . 1 B 1 . . 1 B 1.5 . . 1 B 2 . 2.5 1 B 2.5 . . . B 3 . . . B 3.5 . . . B 4 . . . B 4.5 . . . C 0 . . . C 0.5 . . . C 1 1 . 1 C 1.5 . . 1 C 2 . . 1 C 2.5 . . 1 C 3 . 3 1 C 3.5 . . . C 4 . . . C 4.5 . . . C 5 5 . 1 C 5.5 . . 1 C 6 . 6 1 C 6.5 . . . C 7 . . . C 7.5 7.5 . 1 C 8 . . 1 C 8.5 . 8.5 1 C 9 . . . C 9.5 . . . C 10 . . .
Here is one way
data have;
input LAYER_NAME $1 MD_FT 3-5 Top_layer 7-9 Bottom_layer 11-13;
infile datalines dlm='|';
datalines;
A|0 |. |.
A|0.5|. |.
A|1 |. |.
A|1.5|1.5|.
A|2 |. |.
A|2.5|. |.
A|3 |. |.
A|3.5|. |.
A|4 |. |.
A|4.5|. |.
A|5 |. |.
A|5.5|. |5.5
A|6 |. |.
A|6.5|. |.
A|7 |. |.
A|7.5|7.5|.
A|8 |. |.
A|8.5|. |.
A|9 |. |9
A|9.5|. |.
A|10 |. |.
B|0 |. |.
B|0.5|0.5|.
B|1 |. |.
B|1.5|. |.
B|2 |. |2.5
B|2.5|. |.
B|3 |. |.
B|3.5|. |.
B|4 |. |.
B|4.5|. |.
C|0 |. |.
C|0.5|. |.
C|1 |1 |.
C|1.5|. |.
C|2 |. |.
C|2.5|. |.
C|3 |. |3
C|3.5|. |.
C|4 |. |.
C|4.5|. |.
C|5 |5 |.
C|5.5|. |.
C|6 |. |6
C|6.5|. |.
C|7 |. |.
C|7.5|7.5|.
C|8 |. |.
C|8.5|. |8.5
C|9 |. |.
C|9.5|. |.
C|10 |. |.
;
data want;
set have;
if Top_layer ne . then mark=1;
if Bottom_layer ne . then do;
output;
mark=.;
return;
end;
output;
retain mark;
run;
Result:
LAYER_NAME DEPTH Top_layer Bottom_layer MARK A 0 . . . A 0.5 . . . A 1 . . . A 1.5 1.5 . 1 A 2 . . 1 A 2.5 . . 1 A 3 . . 1 A 3.5 . . 1 A 4 . . 1 A 4.5 . . 1 A 5 . . 1 A 5.5 . 5.5 1 A 6 . . . A 6.5 . . . A 7 . . . A 7.5 7.5 . 1 A 8 . . 1 A 8.5 . . 1 A 9 . 9 1 A 9.5 . . . A 10 . . . B 0 . . . B 0.5 0.5 . 1 B 1 . . 1 B 1.5 . . 1 B 2 . 2.5 1 B 2.5 . . . B 3 . . . B 3.5 . . . B 4 . . . B 4.5 . . . C 0 . . . C 0.5 . . . C 1 1 . 1 C 1.5 . . 1 C 2 . . 1 C 2.5 . . 1 C 3 . 3 1 C 3.5 . . . C 4 . . . C 4.5 . . . C 5 5 . 1 C 5.5 . . 1 C 6 . 6 1 C 6.5 . . . C 7 . . . C 7.5 7.5 . 1 C 8 . . 1 C 8.5 . 8.5 1 C 9 . . . C 9.5 . . . C 10 . . .
I'm very grateful
Thank you!
data want;
set have;
retain mark;
if lag(Bottom_layer) then mark=.;
if Top_layer then mark=1;
run;
Thank you very much
I'm very grateful
Methinks the simplest could be:
data want ;
set have ;
retain mark ;
if top_layer then mark = 1 ;
output ;
if bottom_layer then mark = . ;
run ;
Kind regards
Paul D.
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 25. Read more here about why you should contribute and what is in it for you!
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.