BookmarkSubscribeRSS Feed
cho16
Obsidian | Level 7

Hi All,

We are migrating the SAS programs from 9.3 to viya. When we run the below macro code the office hours are created as expected IN 9.3, but in 9.4 the output was different. Not sure what to update on 9.4 to get the same results as in 9.3.

 

%macro time(day,when,table);
data hours1a;
set &table;
format time1 timeampm8. time2 $8. &day.&when.a $7.;
time1=&day.&when;
time2=put(time1,timeampm8.);
if time2='12:00 AM' then time2='00:00 PM';
hr=kscan(time2,1,':');
l=length(ktrim(kleft(hr)));
if l=1 then time2='0'||ktrim(kleft(time2));
&day.&when.a=kcompress(time2,'');
drop time1 time2 l hr;
run;
%mend time;
%time(su,beg1,anc1); %time(su,end1,hours1a); %time(mo,beg1,hours1a); %time(mo,end1,hours1a);
%time(tu,beg1,hours1a); %time(tu,end1,hours1a); %time(we,beg1,hours1a); %time(we,end1,hours1a);
%time(th,beg1,hours1a); %time(th,end1,hours1a); %time(fr,beg1,hours1a); %time(fr,end1,hours1a);
%time(sa,beg1,hours1a); %time(sa,end1,hours1a);

 

data hours2a;
set hours1a;
format sunday1 monday1 tuesday1 wednesday1 thursday1 friday1 saturday1 $50.;
sunday1=subeg1a||'-'||suend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
monday1=mobeg1a||'-'||moend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
tuesday1=tubeg1a||'-'||tuend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
wednesday1=webeg1a||'-'||weend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
thursday1=thbeg1a||'-'||thend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
friday1=frbeg1a||'-'||frend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
saturday1=sabeg1a||'-'||saend1a||'00:00PM-00:00PM 00:00PM-00:00PM';
keep provno sunday1 monday1 tuesday1 wednesday1 thursday1 friday1 saturday1;
run;

 

output: 9.3

cho16_0-1635275284362.png

cho16_0-1635278055559.png

 

output9.4

cho16_1-1635275373237.png

cho16_1-1635278099874.png

 

Thanks .

2 REPLIES 2
ballardw
Super User

Without at least one example of the data sets use for &table it is hard to guess exact issues.

 

First, with debugging macros is to set Options Mprint; before running the problem macro example. See if the LOG contains expected generated code.

I might suggest running the code without the Drop statement so you can examine the values of the intermediate variables you use.

SASKiwi
PROC Star

SAS 9.4 and Viya aren't the same software. Which one is it?

 

I suggest you compare SAS options between 9.3 and 9.4 especially the ones related to language and encoding.

proc options;
run;

The K-type functions are specially designed for DBCS character sets so are likely to be influenced by any change in encoding or language options. 9.4 capabilities for NLS are much enhanced in 9.4 so seeing differences in behaviour are not so surprising.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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