BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
3 REPLIES 3
LinusH
Tourmaline | Level 20
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
deleted_user
Not applicable
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
SushilNayak
Obsidian | Level 7
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

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

 

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.

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
  • 1027 views
  • 0 likes
  • 3 in conversation