Help using Base SAS procedures

Can you set a variable's value during multiple sets?

Reply
Frequent Contributor
Posts: 75

Can you set a variable's value during multiple sets?

Creating 1 pdb from multiple:

DATA  PDB1;

SET PDBA

SET PDBB

SET PDBC

SET PDBD

SET PDBE;

Is there a way to create and set a single variable with a value to distinguish each SET pdb?

PDB=A for all observations from PDBA, so on and so on.....

Jeff

Respected Advisor
Posts: 3,156

Re: Can you set a variable's value during multiple sets?

Super User
Posts: 11,343

Re: Can you set a variable's value during multiple sets?

Do you mean:

SET PDBA;

SET PDBB;

SET PDBC;

SET PDBD;

SET PDBE;

or

SET PDBA

      PDBB

      PDBC

      PDBD

      PDBE;

As written I would expect error messages about not finding the dataset SET.

Regular Contributor
Posts: 195

Re: Can you set a variable's value during multiple sets?

Hi,

If you are going to append the data by using single SET statement, than you can use IN = option to identify the observations...But make sure that you are appending not one - to - one reading by using multiple SET statemsnts...

data test;

   set pdbA(in = a)

        pdbB(in = b)

        pdbC(in = c)

        .....and so on;

    if a then pdb = "A";

    if b then pdb = "B";

    if c then pdb = "C";

    .....and so on;

run;

Make sure you are going to append the datasets rather than one to one reading (Merging)...

-Urvish

Ask a Question
Discussion stats
  • 3 replies
  • 136 views
  • 0 likes
  • 4 in conversation