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

save i have the following data:

Observation
x
y
112
23
32

as you can see, column y is not complete. BUT, all rows in column y should take the same value:

Observation
x
y
112
232
322

Two Questions:

First, I want to know how I can do that on SAS.

Next, I need want to keep observations such that x>=y. How can I do that?

Thanks,

C

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

One way would be:

data want (drop=_:);

  set have (rename=(y=_y));

  retain y;

  if _n_ eq 1 then y=_y;

  if x gt y;

run;

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

One way would be:

data want (drop=_:);

  set have (rename=(y=_y));

  retain y;

  if _n_ eq 1 then y=_y;

  if x gt y;

run;

jkf91
Calcite | Level 5

thanks a lot! that solved the problem! Smiley Happy

just curious though....

what are these two doing?

drop=_:

rename=(y=_y)

thanks,

c

art297
Opal | Level 21

Just a couple of shortcuts.  The rename statement changes the name of variable y, when the file is set, so that it will be seen to be variable _y;  I did it that way so that the later missing values of y wouldn't override the desired value from the first record.

The drop statement, then, just uses the semicolon as a wild card.  It says, in essence, to drop any variable that starts with an underscore (i.e., variable _y).

The semi colon has lots of under used useage in SAS as stated, nicely, in:

http://www2.sas.com/ proceedings/sugi29/054-29.pdf

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 922 views
  • 0 likes
  • 2 in conversation