BookmarkSubscribeRSS Feed
syam_india_kochi
Calcite | Level 5
Hi,

In one of my data set I have 37 numeric columns out which, one numeric column is in date format.

My requirement was to replace all the null values(.) from the data set with zeros and I had used the following array

data liab_asset1;
set liab_asset;
array v(*) _numeric_;
do i = 1 to dim(v);
if v(i) = . then v(i) = 0;
end;
drop i;
run;


But this statement replaces all the null fields from the date field also. If i dont want to do any action on the date field how should I write the query..?

Please help..!!
4 REPLIES 4
Patrick
Opal | Level 21
From a performance point of view there will be better solutions but below approach means only small changes to your existing code.
Make sure to write the name of the var to exclude in capital letters.


data liab_asset1;
set liab_asset;
array v(*) _numeric_;
do i = 1 to dim(v);
if vname(v(i)) ne '' and v(i) = .
then v(i) = 0;
end;
drop i;
run;


SAS knows only 2 datatypes: Numeric and character. A SAS date is stored as a number in a numeric variable - and this number then "interpreted" by applying an appropriate date format.

HTH
Patrick
syam_india_kochi
Calcite | Level 5
Thank you very much Patrick...
syam_india_kochi
Calcite | Level 5
Thank you very much Patrick...
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
As a more direct alternative, consider using the VFORMAT function instead, presuming your SAS DATE variable has a SAS date-type output FORMAT associated.

Scott Barry
SBBWorks, Inc.

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

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1671 views
  • 0 likes
  • 3 in conversation