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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1047 views
  • 0 likes
  • 3 in conversation