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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.