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-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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