BookmarkSubscribeRSS Feed
NataljaK
Obsidian | Level 7

Hi dear friends,

 

I have been user of SAS EG for a long time but I use very rarely programming language in my work.

Now I need to find solution for task, that I can't solve using just SAS EG features.

I have a table and I would like to add n rows with fields f1 and f2 to it depends on makro-variables:v1,v2,v3 

If variable v1 is 0  I have to add 3 row and set the field f2  in each row as  'v1', 'v2', 'v3' ; 

If variable v2 is 0  I have to add 2 row and set the field f2 in each row as   'v2', 'v3';

If variable v3 is 0  I have to add 1 row and set the field f2 in it as    'v3';

 

Thanks in advance ,

 

Natalja

 

 

1 REPLY 1
LinusH
Tourmaline | Level 20

You can solve this in many ways, programmatically.

One way is to have data step that evaluates the macro variable, and does explcit OUTPUT. And the PROC APPEND to you target table.

 

I imagine that you build macro logic to dynamically generate PROC SQL INSERT statments directly into the target table.

Data never sleeps

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1 reply
  • 936 views
  • 0 likes
  • 2 in conversation