IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to intialize field in SAS dataset.


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Mon Jan 17, 2011 6:40 pm
Reply with quote

Hi,
I am fetching data from database via SAS SQL query. Now I an trying to reformat fetched data via SAS statements. I want to initialize one field and want zeros for all records.

Please advise.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Mon Jan 17, 2011 7:49 pm
Reply with quote

Code:
VAR = 0;
RETAIN VAR;
is the easiest way. If you explain -- in detail -- what you're looking for, we can provide a better solution. But based on what you wrote, this code will give you a variable initialized to zero and kept for all observations.

Since you didn't tell us anything about what you want to reformat, just how do you think we can provide any assistance?
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Mon Jan 17, 2011 10:10 pm
Reply with quote

Maybe you want something like this in your proc sql?

select ...
<one or more columns>,
0 as var-name
from <table>
Back to top
View user's profile Send private message
ppandey07

New User


Joined: 27 Nov 2008
Posts: 51
Location: Delhi, India

PostPosted: Mon Jan 17, 2011 10:29 pm
Reply with quote

Robert Sample wrote:
Code:
VAR = 0;
RETAIN VAR;
is the easiest way. If you explain -- in detail -- what you're looking for, we can provide a better solution. But based on what you wrote, this code will give you a variable initialized to zero and kept for all observations.

Since you didn't tell us anything about what you want to reformat, just how do you think we can provide any assistance?


The solution you provided is working for me.
Thank you!!!
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Tue Jan 18, 2011 5:41 pm
Reply with quote

Hi,
RETAIN VAR 0;
would also work, If u want to avoid few keystrokes icon_smile.gif

hope it helps.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Allocated cylinders of a dataset DB2 12
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top