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

Hi Everyone,

To find the Highest value within a give window, I use the proc expand.

Now I want to find the Highest value for a number of window say from 3 to 5. I can run the proc 3 times as below.

However, I would like to make it kind of "do from START to END" so it will provide more flexibility and make the code better controlled.

Can you please help me with that?

Thank you so much.

HHC

data have;
input var1 var2;
datalines;
3 2
4 2
0 5
8 9
6 11
100 20
20 60
40 25
10 6
50 29
100 20
run;


proc expand data=have out=want;
convert var1=max_3/transformout=(MOVmax  3);
convert var1=max_4/transformout=(MOVmax  4);
convert var1=max_5/transformout=(MOVmax  5);
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Why not make a macro .

%macro m(start=,end=)

proc expand data=have out=want;

%do i=&start %to &end ;

convert var1=max_&i /transformout=(MOVmax  &i );

%end;

run;

%mend m;

%m(start=3,end=5)



Xia Keshan

View solution in original post

2 REPLIES 2
Ksharp
Super User

Why not make a macro .

%macro m(start=,end=)

proc expand data=have out=want;

%do i=&start %to &end ;

convert var1=max_&i /transformout=(MOVmax  &i );

%end;

run;

%mend m;

%m(start=3,end=5)



Xia Keshan

hhchenfx
Barite | Level 11

Thank you, Xia.

HHC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 1071 views
  • 0 likes
  • 2 in conversation