Hi Iam running below code and iam getting error.please have a look and kindly help
proc sql;
create table work.W5WITF2 as
select
(case
when Sign='C'
then input(Amt,11)/100
when Sign='D'
then (input(Amt,11)/100)*-1
else
end) as Amt length = 8
format = 11.2
informat = 11.2
label = 'Amt',
(case
when sign1='C'
then input(Amt1 ,11)/100
when sign1='D'
then (input(Amt1 ,11)/100)*-1
else
end) as Amt1 length = 8
format = 11.2
informat = 11.2
label = 'Amt1',
Sign,
sign1
from test
;
quit;
(case
595 when Sign='C'
596 then input(Amt,11)/100
__
22
76
ERROR 22-322: Syntax error, expecting one of the following: a format name, ?.
ERROR 76-322: Syntax error, statement will be ignored.
You need to end formats and informats with a dot for SAS to recognize it as such. Add a . (a dot) after 11 -> 11.
You need to end formats and informats with a dot for SAS to recognize it as such. Add a . (a dot) after 11 -> 11.
The second parameter of the input-function is a format-name and format-names end with . (dot), if they no decimals are specified.
Thanks @andreas_lds & @Patrick .
would you please confirm else is mandatory in CASe fumction?sorry to ask here
If you have further problems, please post the whole log of your step; use the {i} button for posting logs.
@JJP1 wrote:
Thanks @andreas_lds & @Patrick .
would you please confirm else is mandatory in CASe fumction?sorry to ask here
Not at all mandatory:
proc sql; create table junk as select *, case when age=13 then 'A' end as Something from Sashelp.class ; quit;
If I only wanted to set the variable Something for the specific age of 13 and blank otherwise.
Good idea to include an Else? Likely so just so you document what was intended if nothing else.
If you were recoding an existing variable with the intent to leave other values as they already exist then you would need an ELSE. Otherwise then other values end up missing.
/* likely wrong approach*/ proc sql; create table junk as select name,sex,height, case when age=13 then 26 end as Age from Sashelp.class ; quit; /* probably should be*/ proc sql; create table junk as select name,sex,height, case when age=13 then 26 else age end as Age from Sashelp.class ; quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.