Newbie can't write an Insert into or an append query to input five records two columns into a two column table. Help.
Are these tables in SAS or in a database?
If it's SAS then don't use a Delete as it only deletes the records logically and your table (the actual file) would be growing constantly.
With SAS you re-create a table. If you want to maintain the table structure with no rows but all the columns and their attributes then use the following code.
/* option 1 */
data ShipAlt.PRICINGINFO;
stop;
set ShipAlt.PRICINGINFO;
run;
/* option 2 */
data ShipAlt.PRICINGINFO;
set ShipAlt.PRICINGINFO (obs=0);
run;
With tables in a database: Don't use a normal SQL DELETE but a TRUNCATE in pass-through SQL as this is much faster (syntax will depend on the database).
For appending data to a SAS table: Proc Append or the SQL OUTER UNION CORR.
proc append base=ShipAlt.PRICINGINFO data=WORK.MECH_PRICING;
run;
proc append base=ShipAlt.PRICINGINFO data=WORK.DLA_PRICING;
run;
What have you tried so far?
Have you been getting error messages? If so, what are they.
Can't seem to get this started I tried insert into and append didn't save the code I am also new to this forum.
PROC SQL;
CREATE TABLE ShipAlt.PRICINGINFO AS
SELECT * FROM WORK.MECH_PRICING
OUTER UNION CORR
SELECT * FROM WORK.DLA_PRICING
;
Quit;
My predecessor wrote the following I would prefer to empty this and append the new dataset and I have a temp dataset of five values I need to append to Princinginfo. I am just a bit lost working with the datatypes. The first column of PrincingInfo is a $Char9 field and the second i believe is an 11.1 I just need to input a currency or a numeric value of whole numbers and a two point decimal.
i think i'd like to try something like the following instead of creating a new table each time?
Proc SQL;
DELETE * FROM ShipAlt.PricingInfo;
Proc SQL;
INSERT INTO ShipAlt.PricingInfo
/* with applicable code to input his code created a new table each time didn't it?
SELECT DISTINCT t1.NIIN, t2.STD_PRICE
FROM SHIPALT.FMPMIS t1
INNER JOIN CROSSREF.V_ITEMS_MECH t2 ON (t1.NIIN = t2.NIIN)
ORDER BY t1.NIIN;
/* this code created a new table each time and it seems to inheirit the datatypes and lengths from the FMPMIS table I will try to employ your put statement for the string value of nine characters but how to format a whole number and two position decimal in the second column of PrincingInfo?
Are these tables in SAS or in a database?
If it's SAS then don't use a Delete as it only deletes the records logically and your table (the actual file) would be growing constantly.
With SAS you re-create a table. If you want to maintain the table structure with no rows but all the columns and their attributes then use the following code.
/* option 1 */
data ShipAlt.PRICINGINFO;
stop;
set ShipAlt.PRICINGINFO;
run;
/* option 2 */
data ShipAlt.PRICINGINFO;
set ShipAlt.PRICINGINFO (obs=0);
run;
With tables in a database: Don't use a normal SQL DELETE but a TRUNCATE in pass-through SQL as this is much faster (syntax will depend on the database).
For appending data to a SAS table: Proc Append or the SQL OUTER UNION CORR.
proc append base=ShipAlt.PRICINGINFO data=WORK.MECH_PRICING;
run;
proc append base=ShipAlt.PRICINGINFO data=WORK.DLA_PRICING;
run;
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.