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

Hi.

In SAS EG my results are opened in the Output Window automatically.  I like this.

 

In SAS EG using Proc SQL I can change the displayed variable output in the Output Window my specifying a format in the SELECT statement like this.  By doing this the myNewDollar variable appears in the Output Window looking like $100.00.

 

proc sql;

create table Want as

select myDollar format dollar15.2 as myNewDollar

from Have;

quit;

 

However when using the SAS datastep in SAS EG, when the Output Window is populated the variable is not formatted as desired. It is display as 100.00 (without the $ sign)

  

data Want;
set Have;
format myNewDollar dollar15.2;

myNewDollar = myExistingDollar;

run;

 

I'm wondering if it's possible to get the variable output to the Output Window formatted using the data step without having to add additional Procs like a Proc Print?

 

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

When you say "output window" -- you meant the data grid view?  This should be showing you the formatted data.  If it works for PROC SQL then it will work for DATA step -- does not matter how the format is set.

 

Make sure that you're looking at the correct data source.  It's possible that you're creating multiple different data sets, and looking at one that doesn't have the format applied.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

3 REPLIES 3
ChrisHemedinger
Community Manager

When you say "output window" -- you meant the data grid view?  This should be showing you the formatted data.  If it works for PROC SQL then it will work for DATA step -- does not matter how the format is set.

 

Make sure that you're looking at the correct data source.  It's possible that you're creating multiple different data sets, and looking at one that doesn't have the format applied.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
TomKari
Onyx | Level 15

I concur with @ChrisHemedinger. I just did a quick test, and it worked fine for me.

 

My test code:

 

data class;
	set sashelp.class;
	format NWeight dollar15.2;
	NWeight = Weight;
run;

 

Tom

buechler66
Barite | Level 11
Yup, you are absolutely correct. Thanks for taking the time to identify my issue. I appreciate it.

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 2435 views
  • 3 likes
  • 3 in conversation