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? )
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.
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.
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
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;
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
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.