BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pablorodriguez1
Calcite | Level 5

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;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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;
--
Paige Miller
ballardw
Super User

Note that you could replace:

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

with:

 

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

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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