proc-sql

SAS proc sql returning duplicate values of group by/order by variables

心不动则不痛 提交于 2019-12-10 20:26:36
问题 I have some fairly simple SQL that should provide 1 row per quarter per asset1. Instead, I get multiple rows per group by. Below is the SQL, a SAS data step, and some of the output data. The number of duplicate rows (in the below data, 227708) is equal to Num_borrowers, which is the asset1 number of rows. proc sql outobs=max; create table table1 as select case when period_dt ='01DEC2003'd then '2003Q4' when period_dt ='01DEC2004'd then '2004Q4' when period_dt ='01DEC2005'd then '2005Q4' when

SAS - What is the SQL language used in a PROC SQL?

ε祈祈猫儿з 提交于 2019-12-06 16:34:40
I'm new to SAS and I'm using the PROC SQL functionality. I can not understand which is the sql language used in the PROC SQL. It seems similar to Oracle-Sql but some functions are not available. Can anyone clarify this point? PROC SQL supports the ANSI SQL definition from 1992. You can also use most SAS functions. International Organization for Standardization (ISO): Database SQL. Document ISO/IEC 9075:1992. Also, as American National Standards Institute (ANSI) Document ANSI X3.135-1992 http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm

SAS Proc SQL Database Table Insert

不打扰是莪最后的温柔 提交于 2019-12-06 09:16:18
问题 Using SAS's Proc SQL, is there a way to insert records from a SAS Dataset into a table in the open SQL Server connection? Something like this (which doesn't work): proc sql exec; connect to sqlservr as DataSrc (server=my-db-srvr database=SasProcSqlTest); create table Items as select * from connection to DataSrc ( SELECT * FROM tblItem ); update Items set Name = Name + Name, Value * 2; insert into tblItem (Name, Value) select Name, Value from Items; disconnect from DataSrc;quit;run; quit; run;

SAS Proc SQL Database Table Insert

為{幸葍}努か 提交于 2019-12-04 15:33:09
Using SAS's Proc SQL, is there a way to insert records from a SAS Dataset into a table in the open SQL Server connection? Something like this (which doesn't work): proc sql exec; connect to sqlservr as DataSrc (server=my-db-srvr database=SasProcSqlTest); create table Items as select * from connection to DataSrc ( SELECT * FROM tblItem ); update Items set Name = Name + Name, Value * 2; insert into tblItem (Name, Value) select Name, Value from Items; disconnect from DataSrc;quit;run; quit; run; To my knowledge, using pass through SQL constrains you to the database server. The SAS documentantion

Dropping a table in SAS

夙愿已清 提交于 2019-12-04 01:13:07
What is the most efficient way to drop a table in SAS? I have a program that loops and drops a large number of tables, and would like to know if there is a performance difference between PROC SQL; and PROC DATASETS; for dropping a single table at a time.. Or if there is another way perhaps??? If it is reasonable to outsource to the OS, that might be fastest. Otherwise, my unscientific observations seem to suggest that drop table in proc sql is fastest. This surprised me as I expected proc datasets to be fastest. In the code below, I create 4000 dummy data sets then try deleting them all with

proc transpose with duplicate ID values

百般思念 提交于 2019-12-02 11:13:13
I need help with proc transpose procedure in SAS. My code initially was: proc transpose data=temp out=temp1; by patid; var text; Id datanumber; run; This gave me error "The ID value " " occurs twice in the same BY group". I modified the code to this: proc sort data = temp; by patid text datanumber; run; data temp; set temp by patid text datanumber; if first.datanunmber then n = 0; n+1; run; proc sort data = temp; by patid text datanumber n; run; proc transpose out=temp1 (drop=n) let; by patid; var text; id datanumber; run; This is giving me error: variable n is not recognized. Adding a let

proc sql vs data step for looking up values form a reference table that includes exceptions

谁说我不能喝 提交于 2019-12-02 10:12:48
问题 I am trying to find out tax values for a particular good in a particular city in a particular state. Tax values are in a reference table like this: state city Good tax --------------------------------- all all all 0.07 all all chicken 0.04 all jackson all 0.01 arizona all meat 0.02 arizona phoenix meat 0.04 arizona tucson meat 0.03 hawaii all all 0.08 nevada reno cigar 0.11 nevada vegas cigar 0.13 Now lets say if I am looking for tax for (nevada reno cigar) an exact match exists in the

proc sql vs data step for looking up values form a reference table that includes exceptions

孤者浪人 提交于 2019-12-02 03:26:16
I am trying to find out tax values for a particular good in a particular city in a particular state. Tax values are in a reference table like this: state city Good tax --------------------------------- all all all 0.07 all all chicken 0.04 all jackson all 0.01 arizona all meat 0.02 arizona phoenix meat 0.04 arizona tucson meat 0.03 hawaii all all 0.08 nevada reno cigar 0.11 nevada vegas cigar 0.13 Now lets say if I am looking for tax for (nevada reno cigar) an exact match exists in the reference so the answer is 0.11. But, if I look for (nevada reno chicken) an exact match does not exist, but

Limiting results in PROC SQL

不问归期 提交于 2019-11-29 22:29:41
I am trying to use PROC SQL to query a DB2 table with hundreds of millions of records. During the development stage, I want to run my query on an arbitrarily small subset of those records (say, 1000). I've tried using INOBS to limit the observations, but I believe that this parameter is simply limiting the number of records which SAS is processing. I want SAS to only fetch an arbitrary number of records from the database (and then process all of them). If I were writing a SQL query myself, I would simply use SELECT * FROM x FETCH FIRST 1000 ROWS ONLY ... (the equivalent of SELECT TOP 1000 *

Limiting results in PROC SQL

一世执手 提交于 2019-11-28 19:09:27
问题 I am trying to use PROC SQL to query a DB2 table with hundreds of millions of records. During the development stage, I want to run my query on an arbitrarily small subset of those records (say, 1000). I've tried using INOBS to limit the observations, but I believe that this parameter is simply limiting the number of records which SAS is processing. I want SAS to only fetch an arbitrary number of records from the database (and then process all of them). If I were writing a SQL query myself, I