BookmarkSubscribeRSS Feed
Sharath_naik
Obsidian | Level 7

Conditions Leve 1 & Level 2 are Indicator for next segment So conditions won't Apply for these two level.

 

Whenever F_there column has "F" value and Blank_90 column has (" " / 90) value then those line need to be highlighted and if these things appear in a any level apart from I and 2 level then below need to be highlighted until Same level appear again.

 

In below example I have 2 segments and I need green things need to be marked has NA , Because in yellow line you can see level 3 which has (F and blank) value satisfy the condition so we need lines from 3 to Next appearing 3

 

I have attached excel , PLease help me to sort it out .

For any querry please post here 

 

 

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Any code we would write would have to work on the corresponding SAS data set and not on the Excel file. Furthermore, many of us refuse to download Microsoft Office files as they can be a security threat.

 

So please provide us with the SAS data set, by following these instructions. Do not provide the data set any other way.

--
Paige Miller
Sharath_naik
Obsidian | Level 7

Hi Sir,

 

I have noted you instruction and in future I will not share any data via excel 

 

here is the dataset .

 

data _1;
infile datalines dsd truncover;
INPUT Level:8. F_there:$1. Blank_90:8.;
DATALINES ;
1,x,20
2,x,20
3,F,29
3,F,
4,F,
4,s,90
5,s,
5,s,91
3,F,90
3,s,3
4,s,30
3,S,30
1,X,20
2,X,20
3,X,20
3,S,20
4,F,91
4,F,90
5,,90
6,F,
7,F,
4,,10
3,S,20
1,,20
;;
RUN;

Sharath_naik
Obsidian | Level 7
Here is the dataset :

data _1;
infile datalines dsd truncover;
INPUT Level:8. F_there:$1. Blank_90:8.;
DATALINES ;
1,x,20
2,x,20
3,F,29
3,F,
4,F,
4,s,90
5,s,
5,s,91
3,F,90
3,s,3
4,s,30
3,S,30
1,X,20
2,X,20
3,X,20
3,S,20
4,F,91
4,F,90
5,,90
6,F,
7,F,
4,,10
3,S,20
1,,20
;;
RUN;
ballardw
Super User

I don't see any values for Blank_90  of " (" " / 90) " . If that is supposed to mean "Blank_90 is blank (or missing) or has a value of "90" then say so. Your original statement implies something entirely different.

PaigeMiller
Diamond | Level 26

@Sharath_naik wrote:

Conditions Leve 1 & Level 2 are Indicator for next segment So conditions won't Apply for these two level.

 

Whenever F_there column has "F" value and Blank_90 column has (" " / 90) value then those line need to be highlighted and if these things appear in a any level apart from I and 2 level then below need to be highlighted until Same level appear again.

 

In below example I have 2 segments and I need green things need to be marked has NA , Because in yellow line you can see level 3 which has (F and blank) value satisfy the condition so we need lines from 3 to Next appearing 3

 

I have attached excel , PLease help me to sort it out .

For any querry please post here 

 

 


Please also show us the desired output. A screen capture is fine, please use the "Insert Photos" icon to include your screen capture in your reply.

 

Please explain what you mean by "need to be highlighted". In a SAS data set, there is no such thing as a "highlight".

Capture.PNG

--
Paige Miller
mkeintz
PROC Star

Thank you for supplying your sample data as a working DATA step.  I don't see a similar sample of the corresponding expected output, but I suspect this is what you want:

 

data _1;
infile datalines dsd truncover;
INPUT Level:8. F_there:$1. Blank_90:8.;
DATALINES ;
1,x,20
2,x,20
3,F,29
3,F,
4,F,
4,s,90
5,s,
5,s,91
3,F,90
3,s,3
4,s,30
3,S,30
1,X,20
2,X,20
3,X,20
3,S,20
4,F,91
4,F,90
5,,90
6,F,
7,F,
4,,10
3,S,20
1,,20
;;
RUN;

data want (drop=_:);
  set _1;
  retain status '  '         /* Either "NA" or 2 blanks                      */
         _terminate_level .  /* Level which will return status to blank      */
         _countdown .        /* 1 means the following obs starts status="NA" */;

  if _countdown=1 then do;   /* Start NA status */
    status='NA';
    _countdown=.;
  end;
  else if status=' ' and level>2 and blank_90 in (.,90) then do;
    _terminate_level=level;
    _countdown=1;
  end;
  else if level=_terminate_level then call missing(of _:,status);
run;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1362 views
  • 2 likes
  • 4 in conversation