i wanted to value in an already existed variable. visdate is a numeric variable. I used this code.
/*Fixing TOC information*/
DATA Marchsub.CLN1718_E;
SET Marchsub.CLN1718_D;
if visdate=2019-01-19 AND cl_patientid='48095' then toc_vis="1";
if visdate=2017-12-17 AND cl_patientid='50055' then toc_vis="1";
if visdate=2019-02-06 AND cl_patientid='591438' then toc_vis="1";
if visdate=2019-01-17 AND cl_patientid='1091715' then toc_vis="1";
if visdate=2018-09-06 AND cl_patientid='1750418' then toc_vis="1";
if visdate=2019-01-17 AND cl_patientid='1950740' then toc_vis="1";
if visdate=2018-02-16 AND cl_patientid='1961685' then toc_vis="1";
if visdate=2018-08-06 AND cl_patientid='2131239' then toc_vis="1";
if visdate=2018-03-21 AND cl_patientid='2179071' then toc_vis="1";
if visdate=2017-07-24 AND cl_patientid='2485717' then toc_vis="1";
if visdate=2019-02-04 AND cl_patientid='3192471' then toc_vis="1";
if visdate=2017-12-27 AND cl_patientid='3454954' then toc_vis="1";
if visdate=2017-07-17 AND cl_patientid='3471634' then toc_vis="1";
if visdate=2017-12-27 AND cl_patientid='3475545' then toc_vis="1";
RUN;
AND used this code to check if the codes above worked.;
proc freq data=Marchsub.CLN1718_E;
table toc_vis/norow nocol nopercent;
run;
Log says :
272 DATA Marchsub.CLN1718_E;
273 SET Marchsub.CLN1718_D;
274 if cl_patientid='48095' AND visdate=2019-01-19 then toc_vis="1";
275 if cl_patientid='50055' AND visdate=2017-12-17 then toc_vis="1";
276 RUN;
NOTE: There were 3437 observations read from the data set MARCHSUB.CLN1718_D.
NOTE: The data set MARCHSUB.CLN1718_E has 3437 observations and 61 variables.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.00 seconds
But it did not work. Please help me.
Why would the value of VISDATE be equal to 2,019 minus 20 ?
If you want to enter a date literal use a string that is compatible with the DATE informat enclosed in quotes followed by the letter d.
if visdate="19JAN2019"d
AND if cl_patientid is a character string, you might need to left-justify it for the comparison:
left(cl_patientid) = '48095'
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.