I have a data set that need to be updated.
Id
89
180
2003
39123
I need to create a new string var "Unique_A200_2018" based on the id# and A200_2018. So, for id 89, his new Unique_A200_2018 is A200_2018_89. id 39123, the new Unique_A200_2018 is A200_2018_39123 and so on.
New in SAS world, please help. Thanks, Shirley.
@Bintang18 wrote:
This is what I got. I know, I have to fix var property, but how about the invalid argument. Did I miss something?
BTW, id is numeric
Thank you again.
WARNING: In a call to the CATT function, the buffer allocated for the result
was not long enough to contain the concatenation of all the arguments.
The correct result would contain 12 characters, but the actual result
might either be truncated to 1 character(s) or be completely blank,
depending on the calling environment. The following note indicates the
left-most argument that caused truncation.
NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is
invalid.
The CATT() function creates a string which you then assign to a variable (the variable left from the equal sign).
If this variable is not long enough to hold the generated string then you get a log message as above.
Add at the very beginning of your data step a LENGTH statement defining a length long enough for the generated string.
data have;
id=25;
run;
data want;
length newvar $20;
set have;
newvar=catt('A200_2018_',id);
run;
There's a function for that! e.g.:
data want; set have; Unique_A200_2018=catt('A200_2018_',id); run;
Art, CEO, AnalystFinder.com
This is what I got. I know, I have to fix var property, but how about the invalid argument. Did I miss something?
BTW, id is numeric
Thank you again.
WARNING: In a call to the CATT function, the buffer allocated for the result
was not long enough to contain the concatenation of all the arguments.
The correct result would contain 12 characters, but the actual result
might either be truncated to 1 character(s) or be completely blank,
depending on the calling environment. The following note indicates the
left-most argument that caused truncation.
NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is
invalid.
You haven't told us something, but I don't know what that something is. The following worked for me:
data have;
input Id;
cards;
89
180
2003
39123
;
data want;
set have;
Unique_A200_2018=catt('A200_2018_',id);
run;
Art, CEO, AnalystFinder.com
@Bintang18 wrote:
This is what I got. I know, I have to fix var property, but how about the invalid argument. Did I miss something?
BTW, id is numeric
Thank you again.
WARNING: In a call to the CATT function, the buffer allocated for the result
was not long enough to contain the concatenation of all the arguments.
The correct result would contain 12 characters, but the actual result
might either be truncated to 1 character(s) or be completely blank,
depending on the calling environment. The following note indicates the
left-most argument that caused truncation.
NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is
invalid.
Did you copy and paste code from the forum? If the code is not in a code box, such as this opened with the {I}
something = CATT('A200_2018_',var);
or the box from the "running man" icon:
something = CATT('A200_2018_',var);
you might have accidentally picked up some invisible html or similar code. If you did copy/paste then try deleting the line of code and retyping.
I ran into one example on this site where a block of datalines had about one instance of "hidden" characters per line. Went through a lot of run the data step, read the errors, retype a data value. Repeat. The editor did not give any indication what those values might have been, there were "invisible" as far as the editor was concerned.
@Bintang18 wrote:
This is what I got. I know, I have to fix var property, but how about the invalid argument. Did I miss something?
BTW, id is numeric
Thank you again.
WARNING: In a call to the CATT function, the buffer allocated for the result
was not long enough to contain the concatenation of all the arguments.
The correct result would contain 12 characters, but the actual result
might either be truncated to 1 character(s) or be completely blank,
depending on the calling environment. The following note indicates the
left-most argument that caused truncation.
NOTE: Argument 1 to function CATT('A200_2018_',78) at line 40 column 22 is
invalid.
The CATT() function creates a string which you then assign to a variable (the variable left from the equal sign).
If this variable is not long enough to hold the generated string then you get a log message as above.
Add at the very beginning of your data step a LENGTH statement defining a length long enough for the generated string.
data have;
id=25;
run;
data want;
length newvar $20;
set have;
newvar=catt('A200_2018_',id);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.