lundi 30 janvier 2023

How to make sample from table to stay all 1 in some column and randomly select 0 in SAS Enterprise Guide?

I have table in SAS Enterprise Guide like below:

Input data:

Size of table: 500 000 rows, 10 columns

  • 3 000 as 1 in "COL1"

  • 497 000 as 0 in "COL1"

    COL1 COL2 ... COLn
    1 XX ... ...
    0 YY ... ...
    0 YY ... ...
    1 UUU ... ...
    ... ... ... ...

Requirements: I need to create sample of this table with 100 000 observations where:

  • I will have all rows with 1 in "COL1" (3 000) and rest randomly selected 97 000 observations with 0 in "COL1"

Desire output:

Size of table: 100 000 rows, 10 columns

  • 3 000 as 1 in "COL1"

  • 97 000 as 0 in "COL1"

    COL1 COL2 ... COLn
    1 XX ... ...
    0 YY ... ...
    0 YY ... ...
    1 UUU ... ...
    ... ... ... ...

How can I do that in SAS Enterprise Guide or PROC SQL ?




Aucun commentaire:

Enregistrer un commentaire