## SAS Automatic Tracks

Solved
Regular Contributor
Posts: 222

# SAS Automatic Tracks

Hi, today i have a worst doubth.

I'd like to know if SAS has a function or step to create automated tracks from a column.

Example:

Data test;

length Age 8;

input age;

cards;

10

12

34

23

23

45

23

54

67

8

54

45

;

run;

I want SAS to create tracks from Age and flag them, automatically, without writing ifs and do loops.

Age    flag

10     1

12     1

34     2

23     2

23     2

45     3

23     2

54     4

67     4

8       1

54     4

45     3

I'd like to know if SAS can do this automatically, where i only need to update the range 10 by 10, 2 by 2, whatever.

Tks,

Rodrigo D. Elias

Accepted Solutions
Solution
‎07-24-2015 03:38 PM
Super User
Posts: 13,574

## Re: SAS Automatic Tracks

I am not familiar with the term "automated tracks"

You are showing 8 flagged as 1 so what is the rule there?

Also how does 54 end up with 4?

If you have specific intervals with irregular ranges then a custom format would be a likely solution. For that we would need to know all of the ranges of values and the assignment.

If it is some regular rule, likely some combination of rounding or truncation functions.

This creates a flag based on groups of 20 as one example:

Data test;

length Age 8;

input age;

flag = ceil(age/20);

cards;

10

12

34

23

23

45

23

54

67

8

54

45

10

20

21

40

;

run;

All Replies
Regular Contributor
Posts: 222

## Re: SAS Automatic Tracks

When i say flag then is in a range, like in the ages between 10 and 20 is 1, 21 to 40 is 2.

But automatically.

Solution
‎07-24-2015 03:38 PM
Super User
Posts: 13,574

## Re: SAS Automatic Tracks

I am not familiar with the term "automated tracks"

You are showing 8 flagged as 1 so what is the rule there?

Also how does 54 end up with 4?

If you have specific intervals with irregular ranges then a custom format would be a likely solution. For that we would need to know all of the ranges of values and the assignment.

If it is some regular rule, likely some combination of rounding or truncation functions.

This creates a flag based on groups of 20 as one example:

Data test;

length Age 8;

input age;

flag = ceil(age/20);

cards;

10

12

34

23

23

45

23

54

67

8

54

45

10

20

21

40

;

run;

🔒 This topic is solved and locked.