BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gkpf
Fluorite | Level 6
DATA=MYLIB.FILTER_FOR_FLT_WT t2;

array flt_id {249} S_Fri_BR3303_SJCTPE S_Fri_BR3304_TPESJC S_Fri_BR3309_SJCTPE



DO n=1 TO 3;
PROC SQL;
CREATE TABLE MYLIB.FILTER_FOR_MER05 AS 
SELECT t1.Wt_Knw_Ind, 
t1.Pax_key, 
t1.Bag_Cnt, 
t1.Bag_Wt_Msr, 
t1.Unit_Qual_Cd, 
t1.Pool_Ind, 
t1.Pax_Prm_Id, 
t1.Pty_Rk, 
t1.Flt_Id, 
t1.Age, 
t1.Horscp_Nm, 
t1.Nat_Cd, 
t1.Emp_Ind, 
t1.Pax_Typ_Cd, 
t1.Gndr_Cd, 
t1.Title_Cd, 
t1.Tvl_Seq, 
t1.Seg_Id, 
t1.Grp_Ind, 
t1.Obd_Cbn_Cls_Cd, 
t1.Seat_Nbr, 
t1.Trf_Ind, 
t1.Ffp_Carr_Cd, 
t1.Ffp_Typ_Cd, 
t1.Brdg_Stat_Desc
FROM MYLIB.MER05 t1
WHERE t1.Wt_Knw_Ind = flt_id{n};


QUIT;

Hi, I have a problem  with sas array value problem, i try to use several ways to get the value call flt_id (which tells the different flight)

and I try to seperate the data with tons of passenger  by the flt_id, but i cant access the array value and it keep showing 

 

ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &, (, *, **, +, -, '.', /, <, <=, <>, =, >, >=, AND, EQ, EQT,
EXCEPT, GE, GET, GROUP, GT, GTT, HAVING, INTERSECT, LE, LET, LT, LTT, NE, NET, NOT, OR, ORDER, OUTER, UNION, ^, ^=,
|, ||, ~, ~=.

 

I have try different syntax like ( ), [ ] but is not working at all, plz help.

 

(By the way, I'm using SAS EG, and is there an easier way to automatically seperate the data with different flt_id? ) 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Yes, the dataset is sorted by flight and pax_key. That way, you can use BY in SAS procedures to automatically group your analysis, and avoid splitting into multiple datasets.

View solution in original post

5 REPLIES 5
Kurt_Bremser
Super User

You cannot "nest" data and procedure steps. As soon as the SAS interpreter detects

proc sql;

it sees the step boundary of the data step, which is incomplete at that time, and that causes your ERROR.

Aside from the missing semicolon to end the array statement, and the fact that you define the array with 249 elements, but only supply three variable names.

 

What are you trying to achieve? Please supply example data in usable form (data steps with datalines) to illustrate your issue.

gkpf
Fluorite | Level 6

Hi

What I have is a data set of passenger and each individual has

 

pax_key(which tells who they are)

flt_id(which flight they took)

 

so what i try to do is I want to seperate the data by flt_id so that i can analysis the correlation of fuel_cost and other data they give us

(

ex:

S_Fri_BR3303_SJCTPE has one data set of its passenger

S_Fri_BR3304_TPESJC has another one

)

 

So sorry about my previous question, I'm so lost in SAS programming

Kurt_Bremser
Super User

Since SAS always allows group processing, there is no need to separate datasets.

Do

PROC SQL;
CREATE TABLE MYLIB.FILTER_FOR_MER05 AS 
SELECT t1.Wt_Knw_Ind, 
t1.Pax_key, 
t1.Bag_Cnt, 
t1.Bag_Wt_Msr, 
t1.Unit_Qual_Cd, 
t1.Pool_Ind, 
t1.Pax_Prm_Id, 
t1.Pty_Rk, 
t1.Flt_Id, 
t1.Age, 
t1.Horscp_Nm, 
t1.Nat_Cd, 
t1.Emp_Ind, 
t1.Pax_Typ_Cd, 
t1.Gndr_Cd, 
t1.Title_Cd, 
t1.Tvl_Seq, 
t1.Seg_Id, 
t1.Grp_Ind, 
t1.Obd_Cbn_Cls_Cd, 
t1.Seat_Nbr, 
t1.Trf_Ind, 
t1.Ffp_Carr_Cd, 
t1.Ffp_Typ_Cd, 
t1.Brdg_Stat_Desc
FROM MYLIB.MER05 t1
WHERE t1.Wt_Knw_Ind in ("S_Fri_BR3303_SJCTPE","S_Fri_BR3304_TPESJC","S_Fri_BR3309_SJCTPE")
order by t1.Wt_Knw_Ind, pax_key;

QUIT;
gkpf
Fluorite | Level 6

Thanks a lot for the help.

 

I try to run this program it give a sorted data set (seems like)

 

I was wondering if its OK that I can email you to discuss some SAS problem.

 

If it's possible then i will finish this discussion. Again, Thanks a lot

 

Kurt_Bremser
Super User

Yes, the dataset is sorted by flight and pax_key. That way, you can use BY in SAS procedures to automatically group your analysis, and avoid splitting into multiple datasets.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 773 views
  • 0 likes
  • 2 in conversation