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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 1010 views
  • 0 likes
  • 3 in conversation