Help using Base SAS procedures

Help with a data step -

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

Help with a data step -

I have two data sets.  One is automatically generated with a time stamp every second.  The other is field notes of the time where a load is observed to begin, thus establishing a control point.  I want to assign all points after that control point its load number until the next control point.

can anyone suggest a simple way to do this?

in essence I need the following

secondscontrol point load number
125660.
125670.
125680.
1256911
125700.
125710.
125720.
125730.
125740.
125750.
125760.
125770.
125780.
125790.
125800.
125810.
1258212
125830.
125840.
125850.
125860.
125870.
125880.

to become this

secondscontrol point load number
125660.
125670.
125680.
1256911
1257001
1257101
1257201
1257301
1257401
1257501
1257601
1257701
1257801
1257901
1258001
1258101
1258212
1258302
1258402
1258502
1258602
1258702
1258802

Accepted Solutions
Solution
‎05-01-2013 12:12 PM
Contributor
Posts: 41

Re: Help with a data step -

Aha!

data b (drop=loadx);

     set a;

     retain loadx;

     if not missing(load) then loadx = load;

     load = loadx;

run;

maybe someone can explain what "(drop=loadx)" is doing

that is not my common usage of "retain" which I've always used to reorder columns.

View solution in original post


All Replies
Super User
Posts: 19,822

Re: Help with a data step -

retain control_point 0;

if load_number ne . then control_point=load_number;

Contributor
Posts: 41

Re: Help with a data step -

And thank you for that as well... I'll try it.

Solution
‎05-01-2013 12:12 PM
Contributor
Posts: 41

Re: Help with a data step -

Aha!

data b (drop=loadx);

     set a;

     retain loadx;

     if not missing(load) then loadx = load;

     load = loadx;

run;

maybe someone can explain what "(drop=loadx)" is doing

that is not my common usage of "retain" which I've always used to reorder columns.

Super User
Posts: 19,822

Re: Help with a data step -

drops it from the final data set.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 220 views
  • 3 likes
  • 2 in conversation