DATA Step, Macro, Functions and more

Questions about create new data sets and merge them into one

Reply
Occasional Contributor
Posts: 5

Questions about create new data sets and merge them into one

Hi!

I am trying to create 7 new data sets from 2004 to 2010. Then I hope to merge them into one. The result for the first data (i.e. 2004) is fine. But from 2005, the log shows weird results as the attachment. So my questions are:

(1) why did it mention variable PERWT04F is uninitialized while my commands are dealing with PERWT05F

(2) why there are 35 variables in the first part of commands but only 27 variables left after the second part of command

Thank you!

Super User
Posts: 19,770

Re: Questions about create new data sets and merge them into one

Why are those variables in your length statement?

Super Contributor
Posts: 358

Re: Questions about create new data sets and merge them into one

Hi:

Firstly, from your log your second data table has the same name as the first and the SET statement is for the same table.  I think you need to change the names of each of your tables to something like DATA MEPS05, for the first, DATA MEPS06 for the second. and so on.  also each table should have the same set (source table).

Then use:

WHERE YEAR=2005;   for the first,.

WHERE YEAR=2006;  for the second,

etc.

Super User
Posts: 11,343

Re: Questions about create new data sets and merge them into one

MisoLee wrote:

Hi!

(1) why did it mention variable PERWT04F is uninitialized while my commands are dealing with PERWT05F

The variables reported as uninitialized are appearing in your length statement, so they are created. They are not initialized because 1) the dataset in the set statement does not contain them and 2) you do not assign a value to them.

The number of variables differes because some of the variables created by the length statement exist in the data set and match the Keep list but not in the first data step. In the first date step you have keep variables with 05 in the name that will not appear in the second data set because they were not on the keep statement of the second..

Occasional Contributor
Posts: 5

Re: Questions about create new data sets and merge them into one

I figured it out now. Thank everyone for your help!!

Ask a Question
Discussion stats
  • 4 replies
  • 269 views
  • 2 likes
  • 4 in conversation