Hi All,
I hope you can help me. I am trying to create a database depending on varies criteria and I am trying to find a way to pull it all together.
I have, say database1 with values and depending on if a variable received from another source (File1) exists then use values from databases2 that have the variable if exists from File1 . I have identified if the variable exists and now I am trying to set that value from database2 to replace value from database1.
That is the thing I don't know where to start to join things together.
I will try to mock up something that maybe helps better to explain what I am trying to do.
say in database1 if have V_W = "Hello" and if File1 has Var1 = "PPO"
then in database2 where Var1=PPO update database1 with value in database2.
I am struggling with how would I do that.
Create Table OptionSet
as
select a, b, c
if a.V_W = "" or C.V_AWZ = "Y" then a.V_W = b.V_W end;
if a.V_X = "" or C.V_BWZ = "Y" then a.V_X = b.V_X end;
if a.V_Y = "" or C.V_CWZ = "Y" then a.V_Y = b.V_Y end;
if a.V_Z = "" or C.V_DWZ = "Y" then a.V_Z = b.V_Z end;
quit.
I believe it's may be best to start with data. Could you please provide sample data which showcase what you have and then tell us how the desired result should look like.
About terminology: I'm a bit confused what you call "database" and what you call "file". Is database a table in a database and file a SAS table? Or is it something else?
@amyk wrote:
Create Table OptionSet
as
select a, b, c
if a.V_W = "" or C.V_AWZ = "Y" then a.V_W = b.V_W end;
if a.V_X = "" or C.V_BWZ = "Y" then a.V_X = b.V_X end;
if a.V_Y = "" or C.V_CWZ = "Y" then a.V_Y = b.V_Y end;
if a.V_Z = "" or C.V_DWZ = "Y" then a.V_Z = b.V_Z end;
quit.
Really recommend following @Reeza's suggestion of data examples. Your pseudocode above references values of multiple variable from multiple tables, A and C, without any consideration of how A and C should relate to ensure the correct values are considered.
Also multiple basically identical comparison/results often is an indication that maybe the data could be better structured
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.