DATA Step, Macro, Functions and more

creating a flag within arrays

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

creating a flag within arrays

I have one array (h) and want to create another array that creates a flag (1) when the value of array h is bigger than 3.

Find below the code that I am using. Why is it not working?

 data curas.curas_aux2;
    set curas.curas_aux;;
     array h(47);
      array c(47);
            do i=1 to i=47;
        c(i) = 0;
        if h(i) > 3 then do; c(i) = 1;
        end;
    end;

    drop i;
run;

Accepted Solutions
Solution
‎04-19-2017 03:36 PM
Trusted Advisor
Posts: 1,615

Re: creating a flag within arrays

In the future, when some SAS code is not working, please SHOW YOUR SASLOG.

 

do i=1 to i=47;

should say

 

 

do i=1 to 47;

View solution in original post


All Replies
Solution
‎04-19-2017 03:36 PM
Trusted Advisor
Posts: 1,615

Re: creating a flag within arrays

In the future, when some SAS code is not working, please SHOW YOUR SASLOG.

 

do i=1 to i=47;

should say

 

 

do i=1 to 47;
Super User
Posts: 10,500

Re: creating a flag within arrays

Note that you could replace:

c(i) = 0;
        if h(i) > 3 then do; c(i) = 1;
end;

with:

 

c(i) = (h(i) > 3);

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 126 views
  • 0 likes
  • 3 in conversation