/* BEGIN data step with the output table data */ data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} ); /* Set the input set */ set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} ); length _renamed $50; if LabName = 'WESTERN PATHOLOGY CONSULTANTS' THEN _renamed = 'RENO' ELSE _renamed = LabName; "Laboratory_Renamed" = _renamed; /* END data step run */ run;
I think you need a semicolon before the ELSE.
/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
/* Set the input set */
set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
length _renamed $50;
if LabName = 'WESTERN PATHOLOGY CONSULTANTS' THEN
_renamed = 'RENO';
ELSE _renamed = LabName;
Laboratory_Renamed = _renamed;
/* END data step run */
run;
Hello,
If your trying to assign values for _renamed to a new column then you must have the statement as :
Laboratory_Renamed = _renamed;
If you put something in quotes, that means your assigning a string value to the variable.
Thank you @SuryaKiran .
I fixed the line but I still am getting
The action was not successful
ERROR: Expecting an arithmetic operator.
ERROR: Syntax error, statement will be ignored.
ERROR: Expecting an arithmetic operator. (occurred 16 times)
ERROR: Syntax error, statement will be ignored. (occurred 16 times)
I think you need a semicolon before the ELSE.
/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
/* Set the input set */
set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
length _renamed $50;
if LabName = 'WESTERN PATHOLOGY CONSULTANTS' THEN
_renamed = 'RENO';
ELSE _renamed = LabName;
Laboratory_Renamed = _renamed;
/* END data step run */
run;
Thank you @ChrisHemedinger !
That was it. Interesting paradigm. I was thinking like C# or most other programming languages where you don't have to put the only statement of a THEN branch in a block.
Another misconception of mine is that in my code, I expected Laboratory_Renamed to be the new column but it was simply treated as an assignment and ignored. _renamed was instead the column.
Here is the final version working version:
/* BEGIN data step with the output table data */
data {{_dp_outputTable}} (caslib={{_dp_outputCaslib}} );
/* Set the input set */
set {{_dp_inputTable}} (caslib={{_dp_inputCaslib}} );
length Laboratory_Renamed $50;
if LabName = 'WESTERN PATHOLOGY CONSULTANTS' then
Laboratory_Renamed = 'RENO';
else Laboratory_Renamed = LabName;
/*Laboratory_Renamed = _renamed;*/
/* END data step run */
run;
PS: Note to self: learn to program in SAS.
Welcome to SAS! Here, we get paid by the semicolon --- so bring them on!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.