BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Dear All,

Is it possible, to write a program that converts missing values to zero and values of zero to missing for numeric variables using array statement?

Appreciate and thanks a lot for help.

Regards,

S Ravuri.

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

S Ravuri,

It also "will be really helpful going forward" if you could mark Ksharp's answer as "Correct". One 'Click' of yours will help saving many others who share same interest many minutes by leading them right to the point. Besides, who would want to watch movies without endings at the first place?Smiley Wink

Thanks,

Haikuo

View solution in original post

6 REPLIES 6
Ksharp
Super User

From mssing value to zero.

data worked;
input _QueueName $24. _tran_dt :mmddyy8. _tran_tm acct_num workedkey _acct_num;
format _tran_dt mmddyy8. acct_num 16.;

cards;
Inbound                       3/8/2012    172000      3000000000064278  .      3000000000064278
C-VXX-D-CP-XXXXXXX-XXXX       3/7/2012    .     3000000000064278  11918651      3000000000064278
N-PXX-N-CP-XXXXXXXXXXXXX      3/3/2012    213400      2000000000885230  11886991      2000000000885230
N-2XX-N-KE-XXXXXXX            3/4/2012    170800      1000000000801180  11895835      1000000000801180
;
run;
data worked;
 set worked;
 array _x{*} _numeric_;
 do i=1 to dim(_x);
  if missing(_x{i}) then _x{i}=0;
 end;
run;







From zero to missing value



data worked;
input _QueueName $24. _tran_dt :mmddyy8. _tran_tm acct_num workedkey _acct_num;
format _tran_dt mmddyy8. acct_num 16.;

cards;
Inbound                       3/8/2012    172000      3000000000064278  0      3000000000064278
C-VXX-D-CP-XXXXXXX-XXXX       3/7/2012    0     3000000000064278  11918651      3000000000064278
N-PXX-N-CP-XXXXXXXXXXXXX      3/3/2012    213400      2000000000885230  11886991      2000000000885230
N-2XX-N-KE-XXXXXXX            3/4/2012    170800      1000000000801180  11895835      1000000000801180
;
run;
data worked;
 set worked;
 array _x{*} _numeric_;
 do i=1 to dim(_x);
  if _x{i}=0 then _x{i}=.;
 end;
run;



Ksharp

sambasiva_ravuri_tcs_com
Calcite | Level 5

Hello Ksharp,

Codes are worked very well and i really appreciate for your help.

If you don't mind, what is the significance of "_numeric_ "  Automatic variable which you used in the code ?

Can you please share if you have a list of Automatic variables in SAS with explanations and that will be really helpful going forward.

Regards,

S Ravuri.

Haikuo
Onyx | Level 15

S Ravuri,

It also "will be really helpful going forward" if you could mark Ksharp's answer as "Correct". One 'Click' of yours will help saving many others who share same interest many minutes by leading them right to the point. Besides, who would want to watch movies without endings at the first place?Smiley Wink

Thanks,

Haikuo

Ksharp
Super User

_numeric_ is a representor of all the numeric variables in this dataset.

There are some other variable listing way which can save you lots of time in the documentation.You should search it on your own  at support.sas.com   .

Ksharp

Howles
Quartz | Level 8

It's not an automatic variable. It is a SAS Variable List.

http://support.sas.com/documentation/cdl/en/lrcon/62753/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtq...

sambasiva.ravuri@tcs.com wrote:

Hello Ksharp,

Codes are worked very well and i really appreciate for your help.

If you don't mind, what is the significance of "_numeric_ "  Automatic variable which you used in the code ?

Can you please share if you have a list of Automatic variables in SAS with explanations and that will be really helpful going forward.

Regards,

S Ravuri.

sambasiva_ravuri_tcs_com
Calcite | Level 5

Haikuo,

Am already did that. Thanks for suggestion. Am between couple of meetings.So that is the reason am not able to do it on time and am sorry for that.

Regards,

S Ravuri.

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