DATA Step, Macro, Functions and more

first.* is unitialized

Reply
N/A
Posts: 0

first.* is unitialized

I have a set of data comprising of stock code, date and stock return. i want to find the first date of every code. i use the following:
proc sort data=p05;
by code date;
run;

data pp05;
set p05;
where FIRST.code =1;
run;

ERROR: Syntax error while parsing WHERE clause.
ERROR 180-322: Statement is not valid or it is used out of proper order.

and , where to find errow 189-322?
Super User
Posts: 5,260

Re: first.* is unitialized

In order to use first. syntax, you must use a BY statement in your data step: BY code;
The =1 is unnecessary, it is implied TRUE. And I don't believe you can use FIRST. together with WHERE (since WHERE does not aware of what is going on in the data step, IF is).

/Linus
Data never sleeps
N/A
Posts: 0

Re: first.* is unitialized

tried the following:

proc sort data=p05;
by code ;
run;

data pp05;
set p05;
if FIRST.code ;
run;

but still doesn't work. so i guess maybe something is wrong with my SAS. i am going to school to use another computer to try
anyway, thank
Contributor
Posts: 31

Re: first.* is unitialized

Hey tzsmile,
you forgot to put the by variable in the datastep...

proc sort data=p05;
by code ;
run;

data pp05;
set p05;
by code ;
if FIRST.code ;
run;

just add "by code ;" in the datastep like i have done in the above code and you'll see your code without any errors/ warnings.
Ask a Question
Discussion stats
  • 3 replies
  • 134 views
  • 0 likes
  • 3 in conversation