BookmarkSubscribeRSS Feed
teja5959
Obsidian | Level 7

Hi here i have a small  issue in base sas . i have assain blfl variable 'Y' here how to avoied before value 

 


data ex;
input pi test$ result;
cards;
101 gluk 130
101 gluk 140
101 gluk 158
101 gluk 148
101 gluk 145
101 gluk 148
101 prot 200
101 prot 210
101 prot 220
101 prot 290
101 prot 220
101 prot 217
;
run;

 

data exp;
set ex;
by pi result;
retain;
if result=140 or result=210 then blfl='Y';
else blfl='.';

run;

2 REPLIES 2
Kurt_Bremser
Super User

The by statement causes and error because the dataset ex is not properly sorted.

The retain statement without a variable has no effect.

Could you please post the intended result?

Astounding
PROC Star

I agree with Kurt, you need to show what your intended result is.  Here is a guess:

 

data want;

set have;

by pi test;

if first.test=0 then blfl='Y';

run;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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