Hi, Is there a way to ensure that missing entries for character fields have blanks and missing entries for numeric fields have the decimal point when importing data and when working datsets. Thanks.
data ListFinal;
set ListFinal;
array NumVar _numeric_;
do over NumVar;
if NumVar < 0 and NumVar not in (.) then NumVar=.;
end;
run;
data ListFinal;
set ListFinal;
array CharVar _character_;
do over CharVar;
if CharVar in ('.',''," ",' ') then CharVar='';
end;
run;
Hi @twildone ,
Do you mean situation where you have data already in sas dataset, or when you are reading from a text file?
Btw. in case of text variables:
" " = "" = '' = ' '
All the best;
Bart
PS you can do your code in 1 datastep (one data read/write):
data ListFinal;
set ListFinal;
array NumVar _numeric_;
array CharVar _character_;
do over NumVar;
if not (NumVar > .z) then NumVar=.;
end;
do over CharVar;
if CharVar in ('.',' ') then CharVar='';
end;
/* what about this case: ' .' ?*/
run;
Hi...when I am reading in from a text file....thanks
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.