BookmarkSubscribeRSS Feed
paulrockliffe
Obsidian | Level 7

I have the programme below that I use in Enterprise Guide to subset a massive table.  I want to add some calculated fields at the same time, to allow me to subset the table further for various conditions.

 

How do I do that?

 

data WORK.EXAMPLE (keep = Var1 Var2 Var3 Var4 Var5) ;

 

if 0 then set WORK.HASH WORK.SOURCE;

if _n_ = 1 then do;

declare hash l (dataset:"WORK.HASH");
l.definekey("Var2");
l.definedata("Var2r", "Var1", "Var3");
l.definedone();

end;

set WORK.SOURCE ;

if l.find() = 0

Output;

Run;

 

I can do it quite easily with Query Builder, but I'm trying to avoid creating a second copy of the data on my server - The initial subset creates a 14Gb file, so it's not one to duplicate!

 

Thanks.

5 REPLIES 5
paulrockliffe
Obsidian | Level 7

Thanks, you couldn't just add a quick example for me, I'm not sure I really have the syntax for this straight in my head!

 

Cheers

paulrockliffe
Obsidian | Level 7

Thanks,  I'm creating a key by concatenating two of my variables and a flag that is 1 if one of the variables is over 100.

 

I want to add those as new variables rather than subsetting directly as I'm running a few different operations from the resulting dataset.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 5 replies
  • 1590 views
  • 0 likes
  • 2 in conversation