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

Hi all,

 

I'm using SAS Studio from SAS onDemand for Academics and I'm running into problems with directives from the PICTURE statement. Suppose I wish to display the year in my output:

 

proc format;
picture dnt
other='%Y        ' (datatype=datetime);
run;
data tmp;
input date_time datetime21.;
format date_time dnt.;
cards;
12mar2016 11:05:00 pm
;
run;
proc print;
run; 

 

If you compile this program it will successfully run with the output "2016". Now, let's say for some reason I change my mind and I want to display the month instead, all I do is to modify the directive as follows:

 

proc format;
picture dnt
other='%B        ' (datatype=datetime);
run;
data tmp;
input date_time datetime21.;
format date_time dnt.;
cards;
12mar2016 11:05:00 pm
;
run;
proc print;
run;

 

However, if you run the code above the output will NOT be automatically updated to "March". I tried everything I could to solve this problem and the only way I found was to reset the entire SAS session which is quite annoying. Is this a bug or is there any workaround to fix this issue?

 

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

What do you mean the results are not automatically update? 

Also consider explicitly referencing the data in your proc prints. It's not required but helps avoid errors. 

What happens if you use a diff format name?

 

If the error persists Please post your log. 

View solution in original post

6 REPLIES 6
Reeza
Super User

What do you mean the results are not automatically update? 

Also consider explicitly referencing the data in your proc prints. It's not required but helps avoid errors. 

What happens if you use a diff format name?

 

If the error persists Please post your log. 

expertyejin
Obsidian | Level 7

Thank you very much Reeza! Smiley Happy I guess whenever I use a PROC FORMAT the format(s) I choose are somehow "inscribed" into SAS's internal memory and "bound" to directives associated with it, meaning whenever I wish to pick a different directive I also have to use a different format as well. 

expertyejin
Obsidian | Level 7

Actually Reeza, today I tried my code again and made some minor modifications. It turns out that one way to fix this issue is to place the FORMAT statement in the PRINT procedure rather than the DATA step. Not sure about the reason for this and hope you could explain why? Thank you.

Reeza
Super User

Your original issue was incorrect, the new proc format should have overwritten the old one. 

 

I think ink the proc print without data set pointers is th issue. 

 

I'll try and test it tomorrow unless someone else has. 

Reeza
Super User

I tested and CANNOT replicate your issue.

If you can replicate the issue, then I highly suggest that you report it to SAS tech support.

 

In fact, all you have to do is change the definition, you don't even have to re-read the dataset or reapply the format.

 

ods pdf file='C:\_localdata\output1.pdf' startpage=never;
proc format;
picture dnt
other='%Y        ' (datatype=datetime);
run;
data tmp;
input date_time datetime21.;
format date_time dnt.;
cards;
12mar2016 11:05:00 pm
;
run;
proc print data=tmp;
run; 

proc format;
picture dnt
other='%B        ' (datatype=datetime);
run;

proc print data=tmp;
run;
ods pdf close;

 

delete diff format.JPG

 

expertyejin
Obsidian | Level 7
I actually contacted the tech support team and it really turns out to be a defect which is only present in SAS Studio. You are right about the workaround to fix this issue for the time being, which is to use another format. And by the way, you can ONLY replicate this issue in SAS University Edition or SAS onDemand for Academics, SAS Studio. Please see the problem note: http://support.sas.com/kb/57/730.html

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