BookmarkSubscribeRSS Feed
JayCompany
Calcite | Level 5

Hello,

   I have a very large dataset with multiple variables. Some of these variables have a value of zero, which I'd like to convert to 'NULL'. How would I go about doing this? 


Eg:

Desciprtion, VariableA#, VariableB#.......VariableZ#

 

 

Thanks! 

3 REPLIES 3
ballardw
Super User

One way assuming all the variables are numeric:

data want;
   set have;
   array v var1 var2 varx;   /* add variables as needed*/
   do i=1 to dim(v);
     if v[i]=0 then v[i]=.;
   end;
   drop i;
run;

 

 

SuryaKiran
Meteorite | Level 14

If the variables are numeric then try this:

 

PROC FORMAT;
value Null .="NULL";
run;
data want;
set Have ;

array Change _numeric_;
do over change;
if change>10 then change=.;
end;
FORMAT _NUMERIC_ Null.;
run;

Thanks,
Suryakiran

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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