BookmarkSubscribeRSS Feed
Tyagii
Calcite | Level 5

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

4 REPLIES 4
Ksharp
Super User

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;
Tyagii
Calcite | Level 5

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

andreas_lds
Jade | Level 19

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;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi, 

 

Like (Note the use of indentation, and finishing a datastep/procedure correctly with run; or quit;) - 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;

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
  • 4 replies
  • 904 views
  • 1 like
  • 4 in conversation