DATA Step, Macro, Functions and more

How do I add dummy values in blank character sas field

Reply
New Contributor
Posts: 3

How do I add dummy values in blank character sas field

data abhi;
input a b c d ;
datalines;
1 2 6 .
2 3 8 .
3 5 9 .
4 6 2 .
5 8 1 .
;
proc print data = abhi;
run;

re

 


results:

a b c d
1 2 6 .
2 3 8 .
3 5 9 .
4 6 2 .

Here we have d which is not having a blank value. Now I want to add some dummy values into the 'd' sas field after this step.
and results should look like given below. Please help me on this.


Dummy values are:
5
6
7
8

results should looks like.

a b c d
1 2 6 5
2 3 8 6
3 5 9 7
4 6 2 8

Super User
Posts: 10,023

Re: How do I add dummy values in blank character sas field

Not Sure I understand what you mean.

 

data abhi;
input a b c d ;
datalines;
1 2 6 .
2 3 8 .
3 5 9 .
4 6 2 .
;
data Dummy;
input Dummy;
cards;
5
6
7
8
;
run;
data want;
 merge abhi Dummy(rename=(Dummy=d));
run;
New Contributor
Posts: 3

Re: How do I add dummy values in blank character sas field

Thanks. you understand correctly. but i dont want to use cards or datalines. Can you please do the same without cards or datalines.

Super Contributor
Posts: 345

Re: How do I add dummy values in blank character sas field

[ Edited ]

Tyagii schrieb:

Thanks. you understand correctly. but i dont want to use cards or datalines. Can you please do the same without cards or datalines.


 

To suggest any datasource other than datalines/cards you have to explain where the dummy-values come from.

 

Using output-statement is always possible ...

 

data Dummy;
  Dummy = 5; output;
  Dummy = 6; output;
/* ... */
;
run;
Super User
Super User
Posts: 7,942

Re: How do I add dummy values in blank character sas field

Hi, 

 

Like (Note the use of indentation, and finishing a datastep/procedure correctly with run; or quitSmiley Wink - code can be placed in posts using the {i} in the toolbar.

data abhi;
  input a b c d;
  d=_n_+4;
datalines;
1 2 6 .
2 3 8 .
3 5 9 .
4 6 2 .
5 8 1 .
;
run;
Ask a Question
Discussion stats
  • 4 replies
  • 217 views
  • 1 like
  • 4 in conversation