DATA Step, Macro, Functions and more

question about assignment statement

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

question about assignment statement

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.


Accepted Solutions
Solution
‎11-01-2017 05:08 PM
Super User
Posts: 23,928

Re: question about assignment statement

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


All Replies
Regular Contributor
Posts: 226

Re: question about assignment statement

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.  

Contributor
Posts: 24

Re: question about assignment statement

Posted in reply to error_prone

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

Super User
Posts: 23,928

Re: question about assignment statement

@SAS_John highlighting doesn't appear in the post

Contributor
Posts: 24

Re: question about assignment statement

Thanks for replies. 

maxdtc=maxsdtc max maxedtc;

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

 

Best,

 

John 

Solution
‎11-01-2017 05:08 PM
Super User
Posts: 23,928

Re: question about assignment statement

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. 

 

 

 

Contributor
Posts: 24

Re: question about assignment statement

Thanks Reeza. Got It

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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