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

I wrote code that I ran one time to get a database in SAS. Instead of delete this code, I tried block commenting it out. It appears that when I do this, it also comments out the following line of code after the block comments unless I add a semicolon at the end of the block comment. 

 

Why does this happen?

 

This is the code that is making my next line be a comment without the semicolon in the last line.

 

/*/*/*/*/*%LET PriorMo = %SYSFUNC(PUTN(%EVAL(&MO -1),z2.));*/*/*/*/*/
/*/*/*/*/*%PUT &=PriorMo;*/*/*/*/*/
/*/*/*/*/*%LET YrPriorMo = &Yr&PriorMo;*/*/*/*/*/
/*/*/*/*/*%PUT &=YrPriorMo;*/*/*/*/*/

/*/*/*/*/*%SYMDEL PriorMo;*/*/*/*/*/

/*/*/*/*/*%LET strDbFilePathPrior = %SYSFUNC(CATX(\*/*/*/*/*/
/*/*/*/*/* ,\\blcfs04\#BLCFS04\HLTHFIN\ONGOING\LTC\Valuation*/*/*/*/*/
/*/*/*/*/* ,&Yr*/*/*/*/*/
/*/*/*/*/* ,&YrPriorMo*/*/*/*/*/
/*/*/*/*/* ,RGA*/*/*/*/*/
/*/*/*/*/* ,People History.accdb)*/*/*/*/*/
/*/*/*/*/* );*/*/*/*/*/
/*/*/*/*/*%PUT &=strDbFilePathPrior;*/*/*/*/*/

/*/*/*/*/*%MsOfficeImport(&strDbFilePathPrior*/*/*/*/*/
/*/*/*/*/* ,Cum Info*/*/*/*/*/
/*/*/*/*/* ,SaDAPHlt.VMF_Cumulative_Info*/*/*/*/*/
/*/*/*/*/* ,strFileType = ACCESS*/*/*/*/*/
/*/*/*/*/* ,strSasGrpNm=ActProdMgmtHealth*/*/*/*/*/
/*/*/*/*/* );*/*/*/*/*/

/*/*/*/*/*%SYMDEL strDbFilePathPrior YrPriorMo;*/*/*/*/*/;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

HINT: Do not use multiple /*/*/*     */*/*/ to comment code. The first /* starts a sequence but nested * and /* start confusing the processor.

Depending on exact code likely one or more of the /* get treated as the start of a * ; type comment. So the first statement following is treated as part of one of those comments, or require the ending ; as you mention.

 

Generally for blocks I use

/*

<all the code >

 

*/

 

to avoid that specific issue.

View solution in original post

2 REPLIES 2
ballardw
Super User

HINT: Do not use multiple /*/*/*     */*/*/ to comment code. The first /* starts a sequence but nested * and /* start confusing the processor.

Depending on exact code likely one or more of the /* get treated as the start of a * ; type comment. So the first statement following is treated as part of one of those comments, or require the ending ; as you mention.

 

Generally for blocks I use

/*

<all the code >

 

*/

 

to avoid that specific issue.

Tom
Super User Tom
Super User

How and Why did you create that wonderful display of gibberish?  From the subject line I suspect that you have mis-used some editor feature.  Remember that editors don't really know what they are editing.  They are just following rules someone gave them.

 

Inserting a bunch of random /* and */ characters into your program is not a good idea. 

Note that /* ... */ comments (block comments) do NOT nest.  So this line 

/*/*/*/*/*%LET PriorMo = %SYSFUNC(PUTN(%EVAL(&MO -1),z2.));*/*/*/*/*/

Is this block comment

/*/*/*/*/*%LET PriorMo = %SYSFUNC(PUTN(%EVAL(&MO -1),z2.));*/

Followed by the beginning of a statement comment ( * .... ; )

*/*/*/*/

So now SAS is on the hunt for a semi-colon to end that comment that you started on the first line.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 4582 views
  • 2 likes
  • 3 in conversation