BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

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.

2 REPLIES 2
Tom
Super User Tom
Super User

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
PGStats
Opal | Level 21

AND if cl_patientid is a character string, you might need to left-justify it for the comparison:

 

left(cl_patientid) = '48095'

PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1363 views
  • 1 like
  • 3 in conversation