View previous topic :: View next topic
|
Author |
Message |
ppandey07
New User
Joined: 27 Nov 2008 Posts: 51 Location: Delhi, India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Maybe you want something like this in your proc sql?
select ...
<one or more columns>,
0 as var-name
from <table> |
|
Back to top |
|
|
ppandey07
New User
Joined: 27 Nov 2008 Posts: 51 Location: Delhi, India
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi,
RETAIN VAR 0;
would also work, If u want to avoid few keystrokes
hope it helps. |
|
Back to top |
|
|
|