Hello everyone,
The following SAS code, why variable bbb can't be a date value like aaa?
Thanks
Mike
%let date=Jan2011;
data test;
length xx $9;
length xx3 $11;
date=symget('date');
xx='01'||date;
xx3=strip(quote(xx));
yy="'"||xx||"'"||"d";
*yy2="'"||"Jan2011"||"'"||"d";
*yy2_2="'"||"01Jan2011"||"'"||"d";
aaa="01Jan2011"d;
bbb=xx3||'d';
yy3="01&date"d;
run;
Are you only trying to accomplish something like?:
%let date=Jan2011;
data test;
format date date9.;
date=input(catt("01",substr("&date.",1,3),substr("&date.",4)),date9.);
run;
When asigning bbb, you are putting the date constant within a string.
When asigning aaa (and yy3), the d-literal is in "open code", which SAS uses during execution time to interpret the contents of the preceding string. Having the data literal within a string will prevent the SAS from interacting with it.
You are confusing date literals with character variables, just because both involve quotes. XX3 is a character variable that happens to have quotes in its value, and then you appended a D when you assigned it to BBB. Result: BBB is a character variable.
SAS only know you are specifying a date literal when the program is being interpreted, not when it is being executed (after all XX3 could just a likely had a value of "abcdef"). Therefore the quotes need to be in the actual SAS script (either explicitly or through interpreting of macro variables). SAS will not look inside the value of XX3 to see that you intended it to be a date literal.
Are you only trying to accomplish something like?:
%let date=Jan2011;
data test;
format date date9.;
date=input(catt("01",substr("&date.",1,3),substr("&date.",4)),date9.);
run;
Arthur,
I have 30 emails from ypou on my inbox again. How hard is it for you to exclude my name from your distribution list? I have put stop on tacking issues and still receive your responses to other individauls's question. Please take a few minutes and exclude my name before you send any replies to anyone.
Thanks
Ellaheh: I am NOT the one sending you emails. You have full control over that in the SAS Forum settings.
Perhaps you marked Art as someone you are "following"?
hi otarod03@nni.com, yu must had set receiving Email notification options and you specify you follow with Dr.Art.
you should login to your account manager to do something.
Thanj you
Mike
Hi,
please check the attached files and follow the three steps to change your email settings. I chose to get notified when Cynthis posts. So when I select Cynthis you should select Art. in step one, click "view all participants", in step two, click "Art", in step 3, click "stop email notification". please let me know if you need further help.
Thank you Art,
base on your code,need is what I need:
%let date=Jan1986;
%let lowdate=Jan1900;
%let update=Jan2112;
data test8;
date=symget('date');
xx=cats('01',date);
need=input(xx,date9.);
lowdate=symget('lowdate');
xx2=cats('01',lowdate);
low=input(xx2,date9.);
update=symget('update');
xx3=cats('01',update);
up=input(xx3,date9.);
if 0 lt need lt 55518 then put 'year of date between 1960 and 2112';
else put 'date illegal';
run;
SAS code was updated by: Mike Davis
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.