Hello,
I would like to use macro variables, but I am not comfortable.
I have a number changing column cond_i from one time to another.
I would like a macro variable that counts the cond_i collones.
To allow to do
if cond_1 to cond_ & i = F then Top = 1 elce Top = 0
Thanks for your idea
| Table | ||||||
| ID | Name | Cond_1 | Cond_2 | Cond_3 | Cond_4 | |
| 1 | tom | F | ||||
| 2 | arthur | F | F | F | F | |
| 3 | didier | F | F | |||
| 4 | françois | F | F | F | F | |
| 5 | harry | F | F | F | ||
| Want | ||||||
| ID | Name | Cond_1 | Cond_2 | Cond_3 | Cond_4 | Top |
| 1 | tom | F | 0 | |||
| 2 | arthur | F | F | F | F | 1 |
| 3 | didier | F | F | F | F | 0 |
| 4 | françois | F | F | F | F | 0 |
| 5 | harry | F | F | F | 0 |
Why does row 3 get the F's filled in? How is that logic defined?
Otherwise, you need arrays not macros.
data want;
set have;
array cond(*) cond_1-cond_4;
top = 1;
do i=1 to dim(cond);
if cond(i) ne 'F' then top=0;
end;
run;
@WilliamB wrote:
Hello,
I would like to use macro variables, but I am not comfortable.
I have a number changing column cond_i from one time to another.
I would like a macro variable that counts the cond_i collones.
To allow to do
if cond_1 to cond_ & i = F then Top = 1 elce Top = 0
Thanks for your idea
Table ID Name Cond_1 Cond_2 Cond_3 Cond_4 1 tom F 2 arthur F F F F 3 didier F F 4 françois F F F F 5 harry F F F Want ID Name Cond_1 Cond_2 Cond_3 Cond_4 Top 1 tom F 0 2 arthur F F F F 1 3 didier F F F F 0 4 françois F F F F 0 5 harry F F F 0
Why does row 3 get the F's filled in? How is that logic defined?
Otherwise, you need arrays not macros.
data want;
set have;
array cond(*) cond_1-cond_4;
top = 1;
do i=1 to dim(cond);
if cond(i) ne 'F' then top=0;
end;
run;
@WilliamB wrote:
Hello,
I would like to use macro variables, but I am not comfortable.
I have a number changing column cond_i from one time to another.
I would like a macro variable that counts the cond_i collones.
To allow to do
if cond_1 to cond_ & i = F then Top = 1 elce Top = 0
Thanks for your idea
Table ID Name Cond_1 Cond_2 Cond_3 Cond_4 1 tom F 2 arthur F F F F 3 didier F F 4 françois F F F F 5 harry F F F Want ID Name Cond_1 Cond_2 Cond_3 Cond_4 Top 1 tom F 0 2 arthur F F F F 1 3 didier F F F F 0 4 françois F F F F 0 5 harry F F F 0
@WilliamB wrote:
Hello,
I would like to use macro variables, but I am not comfortable.
I have a number changing column cond_i from one time to another.
I would like a macro variable that counts the cond_i collones.
To allow to do
if cond_1 to cond_ & i = F then Top = 1 elce Top = 0
You need to use ARRAYs and not macros.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.