Quick question all,
I need Proc Sql syntax for a where statement bring back only records with a string length of 10.
I tried ths and it didn't work:
where a.date_created >=02/20/2018
and length(account_number = 10)
Thanks for any suggestions!
where a.date_created >=02/20/2018
and length(account_number) = 10
where a.date_created >=02/20/2018
and length(account_number) = 10
Strange! Your's matches mine so maybe there was a minor difference between what I posted and what I actually ran. This works. Thanks!
In addition to the suggestion from @novinosrin that moves one of the closing parentheses:
'20Feb2018'd
hi @Dogo23 to help you clarify a bit more, see the below demo
data h;
input var $10.;
datalines;
9999999999
99999
9999999999
8888888888
777777
888
;
data w;
set h;
length=length(var);
length2=length(var)=10;/*your were trying to compute the length of binary result which will always result in 1*/
if length(var=10) then flag=1;/*your were trying to compute the length of binary result*/
run;
Your check was a binary check nested before the length function computes it's work. The nested binary will result in 1 or 0 for values that is 10 and "Not aka 0" for otherwise. The commented section should help i think. Thank you.
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.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.