Hi!
I have a question. Which is the different between this picture?
I don.t understand when the lenght is 200 bytes or the lenght of variable
| The following SAS program is submitted: data work.words; word1='Is'; word2='It'; all=catx(' ',word1,word2); run;The variable All is a character variable of what size?
Correct answer: a | ||||||||
Thanks!!!!!!!!!
Hey,
Cats, Catx, and Cat func always give 200 bytes len for the resulting var, untill unless you do'nt define the length explicitly,
if you use || to concat then you get len of word 1 + word 2, so in ur case
if you use
data work.words; word1='Is'; word2='It'; all=(word1||word2; run;
proc conetnts;run;
in this case you will find 4 len for all variable.
In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, then that variable is given a length of 200 characters. If you need the SCAN function to assign to a variable a word that is longer than 200 characters, then you should explicitly specify the length of that variable.
1- In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, then that variable is given a length of 200 characters. If you need the SCAN function to assign to a variable a word that is longer than 200 characters, then you should explicitly specify the length of that variable.
2- If you use the SCAN function in an expression that contains operators or other functions, a word that is returned by the SCAN function can have a length of up to 32,767 characters, except in a WHERE clause. In that case, the maximum length is 200 characters.
3- In the SQL procedure, or in a WHERE clause in any procedure, the maximum length of a word that is returned by the SCAN function is 200 characters.
4- In the macro processor, the maximum length of a word that is returned by the SCAN function is 65,534 characters.
Source :
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm
I remember @Astounding said before. SAS will decide the length of variable before applying a function. Therefore SAS will take SCAN's variable length as response variable length. But for CATX() , SAS can't decide the variable length ,so using 200 as default length.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.