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

Hi there,

Here I have a situation that I am anticipating variables A to Z in dataset, if we have any variable missing in a resultant dataset then need to initialize that missing variable with a missing value   

 

example:  Expecting A B C D E F G variables in data set, but I got only A B C F variables in a resultant dataset in this case I need to initialize missed out variables D E G with missing value in the resultant dataset.

Any help would be very much appreciated and helps me very much

 

Thanks in advance

Manoj 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Create a blueprint dataset without observations, and prepend that in a SET statement to the actual data:

data expect;
input a b c d e f g;
datalines; 
;

data have;
input a b c f;
datalines;
1 1 1 1
2 2 2 2
;

data want;
set
  expect
  have
;
run;

 

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Create a blueprint dataset without observations, and prepend that in a SET statement to the actual data:

data expect;
input a b c d e f g;
datalines; 
;

data have;
input a b c f;
datalines;
1 1 1 1
2 2 2 2
;

data want;
set
  expect
  have
;
run;

 

LennoxConner
Calcite | Level 5

Hi there,

Here I have a situation that I am anticipating variables A to Z in dataset, if we have any variable missing in a resultant dataset then need to initialize that missing variable with a missing value   

 

example:  Expecting A B C D E F G variables in data set, but I got only A B C F variables in a resultant dataset in this case I need to initialize missed out variables D E G with missing value in the resultant dataset.

Any help would be very much appreciated and helps me very much

 

Thanks in advance

ballardw
Super User

Check this link

https://communities.sas.com/t5/SAS-Programming/Assign-variable-with-missing-valuesd/m-p/672750

 

Then check to see if you can guess who in your class the other poster may be.

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2758 views
  • 1 like
  • 4 in conversation