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

I have this syntax to achieve this result:

 

data have;
     set want;
          array xs(*) var1-var5 
           all = max(of xs(*));
run:

var1      var2     var3     var4     var5     all  

     1           .            .           .          .        1

     .           3            .           .          .        3

     .           .            2           .          .        2

     .           .            .           6          .        6

     .           .            .           .          8        8

 

If I have data like this, where var3 is missing, will the same syntax work for this?

 

var1      var2      var4     var5     all  

     1           .            .          .         1

     .           3            .           .        3

     .           .            2           .        2

     .           6           .            .        6

     .           .            .            8       8

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
     set want;
           all = max(of var: );
run:

View solution in original post

3 REPLIES 3
Ksharp
Super User
data have;
     set want;
           all = max(of var: );
run:
art297
Opal | Level 21

Or, if your variables names don't start with "var", you could use a variable list that only relies on the variable order in the dataset. i.e.:

data want;
     set have;
          array xs(*) var1--var5;
           all = max(of xs(*));
run;

Art, CEO, AnalystFinder.com

 

Tom
Super User Tom
Super User

Yes.

But SAS will create an empty (all missing) variable named VAR3.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 3 replies
  • 655 views
  • 0 likes
  • 4 in conversation