BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS_John
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

This is the MAX operator. 

http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&docsetVer...

 

It works similar to the Max function and takes the max value of the two items on either side. 

 

 

 

View solution in original post

6 REPLIES 6
error_prone
Barite | Level 11

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.  

SAS_John
Obsidian | Level 7

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):

Reeza
Super User

@SAS_John highlighting doesn't appear in the post

SAS_John
Obsidian | Level 7

Thanks for replies. 

maxdtc=maxsdtc max maxedtc;

I run the code and it works. Just want to know the logic behind it.

 

Best,

 

John 

Reeza
Super User

This is the MAX operator. 

http://documentation.sas.com/?docsetId=lrcon&docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&docsetVer...

 

It works similar to the Max function and takes the max value of the two items on either side. 

 

 

 

SAS_John
Obsidian | Level 7

Thanks Reeza. Got It

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1565 views
  • 0 likes
  • 3 in conversation