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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.