does length(“ “)=1? when do you use the length statement versus length('string')?
is “ the same thing as ‘ in SAS?
@clqa wrote:
does length(“ “)=1?
You can find the answer by simply trying this in SAS.
when do you use the length statement versus length('string')?
Length function tells you the length of a string; length statement sets the length of a variabel
is “ the same thing as ‘ in SAS?
If you are writing macros or using macro variables or macro functions/commands, then double-quote is not the same as single-quote. Otherwise, with no macro language, double quote is the same as single-quote.
@clqa wrote:
does length(“ “)=1? when do you use the length statement versus length('string')?
Length statement and Length function are different. One sets the maximum number of bytes a variable used for storage, 3 to 8 in the case of numeric variables, which may limit the precision of storage and calculations of those variables, or 1 to quite a bit longer for character variables.
data junk; x= ' '; y= ' d'; z= 'd '; length q $ 25; q=''; lx=length(x); ly=length(y); lz=length(z); lq=length(q); run;
is “ the same thing as ‘ in SAS?
In this specific case very most definitely not. Whether they occurred from typing or copy and paste neither of those actual characters are a good idea.
“ ‘ " '
The top row above are the characters you typed or ended up in the post for the question. The characters used in programming are on the second row. The top row are often referred to as "smart quotes" as they look more typeset. However they will generally yield errors when used in programming. And one of the reasons we strongly recommend posting and code into the code box the forum opens with the {I} icon. The main message windows will quite often reformat text in a number of ways. Some will yield code that will not run, others change values.
Also look at function lengthn.
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.