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

I had written  the below code

msr='TEST';

            count =1;

            if COALESCE(NEW_GLOBAL_MIN,EXISTING_GLOBAL_MIN) eq . then

                do;

                    msr = msr||'GLOBAL_MIN';

                    count = count+1;

                    put msr;

                    put 'inside 1 if';    

                end;

            if COALESCE(NEW_GLOBAL_MEDIAN,EXISTING_GLOBAL_MEDIAN) = . then

                do;

                    msr = msr||',GLOBAL_MEDIAN';

                    PUT msr;

                    count = count+1;

                end;

            if COALESCE(NEW_GLOBAL_MAX,EXISTING_GLOBAL_MAX) = . then

                do;

                    msr = msr||',GLOBAL_MAX';

                    PUT msr;

                    count = count+1;

                end;

            if COALESCE(NEW_LOCAL_MIN,EXISTING_LOCAL_MIN) = . then

                do;

                    msr = msr||'LOCAL_MIN';

                    PUT msr;

                    count = count+1;

                end;

            if COALESCE(NEW_LOCAL_MEDIAN,EXISTING_LOCAL_MEDIAN) = . then

                do;

                    msr = msr||',LOCAL_MEDIAN';

                    PUT msr;

                    count = count+1;

                end;

            if COALESCE(NEW_LOCAL_MAX,EXISTING_LOCAL_MAX) = . then

                do;

                    msr = msr||',LOCAL_MAX';

                    PUT msr;

                    count = count+1;

                end;

put msr;

put count;

Once this is executed in the end I am expecting values 'TEST GLOBAL MIN GLOBAL MEDIAN ...'etc but I can see only TEST in the log when I print the variable msr at the end.But the value of count is 7 which confirms that all the code in the 6 if statements is executed.

Can you please help me in fixing the above issue.

Thanks

Kiran

1 ACCEPTED SOLUTION

Accepted Solutions
ykk
Obsidian | Level 7 ykk
Obsidian | Level 7

I had updated the code to use trim() while concatenating the 2 variables.I am getting the output correctly now.

View solution in original post

2 REPLIES 2
Reeza
Super User

change the length of the Test variable at the top of your code:

length mar $20.;

msr='TEST';


.... remaining sas code

ykk
Obsidian | Level 7 ykk
Obsidian | Level 7

I had updated the code to use trim() while concatenating the 2 variables.I am getting the output correctly now.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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