Hello,
As indicated in the subject I have 2 date variables A (format: 12DEC2012) and B (format: 20110908) in my data file. I use SAS 9.4 and the following codes, but it always shows A and B are uninitialized. I checked some information from the internet but still do not quite understand how to solve it. Is there anyone can help me figure out the problem?
Codes I use:
data abcd.survey;
if A<B then delete;
run;
Thanks!
As @AskoLötjönen stated, you have no data source in your data step, so A and B are not populated.
You probably want
data abcd.survey;
set abcd.survey;
if A < B then delete;
run;
You are missing set-clause, therefore all of your variables are uninitialized.
As @AskoLötjönen stated, you have no data source in your data step, so A and B are not populated.
You probably want
data abcd.survey;
set abcd.survey;
if A < B then delete;
run;
@Therain, I am going to assume you are relatively new to using SAS. You want to be careful with the word "format" as it has a very specific meaning related to value display. Neither of the values you showed are formats. If the variables are SAS date valued variables then the formats respectively would be Date9. and YYMMDD8. Please confirm by running Proc Contents on the data set that the varibles are date values with formats shown above or is A character and B simply numeric (possibly format Best8. 8.0 or similar) or character.
Thank you! That works very well. Yes, I am a new user of SAS and thanks for the explanation.
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.