Hi,
I am reading other people's code. But not understand one line of the code as the following. Can anybody help me out? Thanks!
data trtdate;
merge trtsdt trtedt;
by usubjid;
maxdtc=maxsdtc max maxedtc;
TRTEDT=input(maxdtc, yymmdd10.);
TR01SDT=TRTSDT;
TR01EDT=TRTEDT;
format trtedt tr01sdt tr01edt yymmdd10.;
keep usubjid trtsdt trtedt tr01sdt tr01edt;
run;
the line of code is highlighted. All maxdtc, maxsdtc and maxedtc are character variables. the purpose of this code is to find the maxdtc between maxsdtc and maxedtc. Just do not understand the logic of this assignment statement.
This is the MAX operator.
It works similar to the Max function and takes the max value of the two items on either side.
I read your post three times, but i don't understand it. Please post the log after executing the datastep.
The line
maxdtc=maxsdtc max maxedtc;
looks like a syntax error.
Here is the log.
606 data trtdate;
607 merge trtsdt trtedt;
608 by usubjid;
609 maxdtc=maxsdtc max maxedtc;
610 TRTEDT=input(maxdtc, yymmdd10.);
611 TR01SDT=TRTSDT;
612 TR01EDT=TRTEDT;
613 format trtedt tr01sdt tr01edt yymmdd10.;
614 keep usubjid trtsdt trtedt tr01sdt tr01edt;
615 run;
NOTE: There were 232 observations read from the data set WORK.TRTSDT.
NOTE: There were 232 observations read from the data set WORK.TRTEDT.
NOTE: The data set WORK.TRTDATE has 232 observations and 5 variables.
NOTE: DATA statement used (Total process time):
@SAS_John highlighting doesn't appear in the post
Thanks for replies.
maxdtc=maxsdtc max maxedtc;
I run the code and it works. Just want to know the logic behind it.
Best,
John
This is the MAX operator.
It works similar to the Max function and takes the max value of the two items on either side.
Thanks Reeza. Got It
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: