Hi SAS Experts,
As soon as I paste in the line makred with /*---1---*/ I get the error below:
_
22
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, ',',
_ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
336 ('MastBeef' ('EB' CATTLE_EB_N CATTLE_EB_P) ('SB' CATTLE_SB_N
336 ! CATTLE_SB_P) ))
_
200
ERROR 200-322: The symbol is not recognized and will be ignored.
If I take the line out, all works fine. Why is that? Is there a limit on nesting?
proc report data=zus split='*';
COLUMNS MAIN_GR SUB_GR PARAMETER
('Beef' (
('Cattle' ('EB' CATTLE_EB_N CATTLE_EB_P) ('SB' CATTLE_SB_N CATTLE_SB_P) ))
('Cow' ('EB' CATTLE_EB_N CATTLE_EB_P) ('SB' CATTLE_SB_N CATTLE_SB_P) ))
('Cow' ('EB' CATTLE_EB_N CATTLE_EB_P) ('SB' CATTLE_SB_N CATTLE_SB_P) )) /*---1---*/
;
DEFINE MAIN_GR / ORDER'Main-*group';
DEFINE SUB_GR / ORDER'Sub-*group';
DEFINE CATTLE_EB_N / 'N';
DEFINE CATTLE_EB_P / 'P';
DEFINE CATTLE_SB_N / 'N';
DEFINE CATTLE_SB_P / 'P';
run;
You appear to have a strange set of bracketing there. If you put them on separate lines, you will see the first ( is closed before the last cow record, hence it will work fine to that point. It is a good example of why Good Programming Practice is important, i.e. consistent casing, spacing, use new rows to split things up etc.:
('Beef'
(
('Cattle'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
('Cow'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
('Cow'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
You appear to have a strange set of bracketing there. If you put them on separate lines, you will see the first ( is closed before the last cow record, hence it will work fine to that point. It is a good example of why Good Programming Practice is important, i.e. consistent casing, spacing, use new rows to split things up etc.:
('Beef'
(
('Cattle'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
('Cow'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
('Cow'
('EB' CATTLE_EB_N CATTLE_EB_P)
('SB' CATTLE_SB_N CATTLE_SB_P)
)
)
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!
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.
Ready to level-up your skills? Choose your own adventure.