I am creating a table and updating the record with some queries.
%let final_File=F_OUTPUT.DS_daily_demand_F;
%let level= (catx('',OPTION_NUMBER,date,fascia));
data &final_File._checkpoints;
format Checkpoints $30. Total_Count 10. comment $100. Check_Date date9.;
run;
proc sql;
update &final_File._checkpoints as a
set
Checkpoints="Total Records",
Total_Count=(select Count(*) from &final_File.),
comment="This is total number cases here",
Check_Date=today();
proc append &final_File._checkpoints=
Checkpoints="Unique record",
Total_Count=(select Count(distinct product_ID) from &final_File.),
comment="This is unique number of cases",
Check_Date=today();
quit;
highlighted portion is not working, how should I write this code.
I have done this in following way...
proc sql;
update &final_File._checkpoints as a
set
Checkpoints="Total Records",
Total_Count=(select Count(*) from &final_File.),
comment="This is total number cases here",
Update_Date=today();
insert into &final_File._checkpoints
set Checkpoints="Unique record",
Total_Count=(select Count(distinct &level.) from &final_File.),
comment="This is unique number of cases",
Update_Date=today();
quit;
It looks like you're trying to alter your &final_File._checkpoints twice - once in your PROC SQL update, and maybe again in your proc append?
If you're updating records use PROC SQL. If you want to stack/add additional records use PROC APPEND with base=<original data set> data=<dataset with new records>. PROC APPEND can't use data step logic like you're trying to do. You can first create a temporary dataset with your new data before appending. See my example here.
You should also look at the PROC APPEND syntax, since it looks like you're completely guessing at it, which usually isn't a great approach for SAS.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
I have done this in following way...
proc sql;
update &final_File._checkpoints as a
set
Checkpoints="Total Records",
Total_Count=(select Count(*) from &final_File.),
comment="This is total number cases here",
Update_Date=today();
insert into &final_File._checkpoints
set Checkpoints="Unique record",
Total_Count=(select Count(distinct &level.) from &final_File.),
comment="This is unique number of cases",
Update_Date=today();
quit;
@Srigyan wrote:
I am creating a table and updating the record with some queries.
%let final_File=F_OUTPUT.DS_daily_demand_F;
%let level= (catx('',OPTION_NUMBER,date,fascia));
data &final_File._checkpoints;
format Checkpoints $30. Total_Count 10. comment $100. Check_Date date9.;
run;
proc sql;update &final_File._checkpoints as a
set
Checkpoints="Total Records",
Total_Count=(select Count(*) from &final_File.),
comment="This is total number cases here",
Check_Date=today();
proc append &final_File._checkpoints=
Checkpoints="Unique record",
Total_Count=(select Count(distinct product_ID) from &final_File.),
comment="This is unique number of cases",
Check_Date=today();
quit;
highlighted portion is not working, how should I write this code.
I suggest copying the Log output for the code that is not working. Copy from the log, the code and all messages related to the code an paste into a code box opened using the forum's {I} icon to preserve formatting.
I am fairly sure you are getting a number of error messages that are actually fairly clear.
Also describe what you actually attempting to do with the append code.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.