Hello,
I am not an expert SAS programmer, I need help with assign value to new variables based on the "D" value "Report_Lev1", "Report_Lev2", "Report_Lev3", and "Report_Lev4". below is data and output:
DATA A;
ID NAME D
1 JOE DOES |-
2 RAY DOES |-|
3 JOHN DOES |-|-
4 JANE DOES |-|-|
5 ANN DOES |-|-|-
6 DAN DOES |-|-|-
7 SCOTT DOES |-|-|
8 ME DOES |-|-|-
9 KIM DOES |-|-|-
10 JANE ME |-|
11 JOE ME |-|-
12 JOHN ME |-|-|
13 ANNE ME |-|-|-
14 TIM ME |-|-|-
15 ANDY ME |-|-|
16 TRACY ME |-|-|-
17 DAVID ME |-|-|-
18 LORI ME |-|-|-
I need help to produce the result below:
ID NAME D Report_Lev1 Report_Lev2 Report_Lev3 Report_Lev4
1 JOE DOES |- BEGIN
2 RAY DOES |-| RAY DOES
3 JOHN DOES |-|- RAY DOES RAY DOES
4 JANE DOES |-|-| RAY DOES JOHN DOES JOHN DOES
5 ANN DOES |-|-|- RAY DOES JOHN DOES JANE DOES ANN DOES
6 DAN DOES |-|-|- RAY DOES JOHN DOES JANE DOES DAN DOES
7 SCOTT DOES |-|-| RAY DOES JOHN DOES JOHN DOES
8 ME DOES |-|-|- RAY DOES JOHN DOES SCOTT DOES ME DOES
9 KIM DOES |-|-|- RAY DOES JOHN DOES SCOTT DOES KIM DOES
10 JANE ME |-| JANE ME
11 JOE ME |-|- JANE ME JANE ME
12 JOHN ME |-|-| JANE ME JOE ME JOE ME
13 ANNE ME |-|-|- JANE ME JOE ME JOHN ME ANNE ME
14 TIM ME |-|-|- JANE ME JOE ME JOHN ME TIM ME
15 ANDY ME |-|-| JANE ME JOE ME JOE ME
16 TRACY ME |-|-|- JANE ME JOE ME ANDY ME TRACY ME
17 DAVID ME |-|-|- JANE ME JOE ME ANDY ME DAVID ME
18 LORI ME |-|-|- JANE ME JOE ME ANDY ME LORI ME
Thank you for your assistance.
If you subtract one from ID into a new dataset
data b; set a; id=id-1; run;
and join a to b by id, you can then work with the next name.
I'm not sure what the logic is for those symbols, but at least it's a start.
The data doesn't make any sense until what logic your using to get the result. @BonnaryW
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.