SAS Automatic Tracks

Accepted Solution Solved
Reply
Regular Contributor
Posts: 212
Accepted Solution

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: 11,343

Re: SAS Automatic Tracks

Posted in reply to DartibaliRodrigo

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;

View solution in original post


All Replies
Regular Contributor
Posts: 212

Re: SAS Automatic Tracks

Posted in reply to DartibaliRodrigo

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: 11,343

Re: SAS Automatic Tracks

Posted in reply to DartibaliRodrigo

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.

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

Discussion stats
  • 2 replies
  • 172 views
  • 4 likes
  • 2 in conversation