Questions tagged [proc-sql]

proc sql is a SAS procedure used to submit SQL statements to the SAS compiler. For Oracle Pro*C, please use [oracle-pro-c].

proc sql; is a SAS procedure used to submit SQL statements to the SAS compiler. It is optionally terminated by a quit; statement. An example of typical syntax would be:

proc sql;
create table z as
  select * 
  from x
  left join y
  on x.id=y.id
  order by 1,2,3;
quit;

A more 'SAS specific' example would be the direct creation of macro variables, such as:

proc sql noprint; 
select someVariable into: MyMacroArray separated by ' ' 
  from work.Input where varCondition='True';

For further details on syntax, click here (v9.4) or here (v9.3)

794 questions
-1
votes
1 answer

SAS- Grouping consecutive dates and finding the count for each group

Just trying to find the most efficient method in doing this. If you have a look at the date column below, you will find two consecutive groups where the last date of the first group being 2018-01-04 and having a total count of 4 and the second…
cc_hey
  • 63
  • 1
  • 11
-1
votes
1 answer

SAS: Approximating runtime/processing time for a query without running

Was wondering if there is a way to estimate the total run time for a query without actually processing the query? I have found when running particular queries it might take hours and I guess it would come in handy to know the approximate completion…
cc_hey
  • 63
  • 1
  • 11
-1
votes
1 answer

Proc SQL dating back 14 whole months

Good afternoon, %let startdate = '2017-01-01'; %let enddate = '2018-07-01'; %let start_dt = '01jan2017:00:00:00'dt; %let end_dt = '01jul2018:00:00:00'dt; I want to automate this Proc SQL so that whenever I run the program it would automatically get…
-1
votes
2 answers

Why does the Compress function not work in SAS Enterprise Guide?

I am currently restructuring my package from SAS Base to SAS Enterprise Guide in a knowledge transfer to a client. Unfortunately, one aspect I have to sacrifice is the change from using compress to strip in my proc sql left joins, for example the…
78282219
  • 593
  • 5
  • 21
-1
votes
2 answers

SAS - proc sql - select columns belonging together?

I want to split a table with many (454) columns in a PROC SQL (perhaps using a macro?) by column names. For example: a column is starting with "Column21....T", "Column22....T", etc. I want to write all those columns starting with "Column21...T"…
SuppaDuppa
  • 13
  • 4
-1
votes
2 answers

How to convert SAS E dates into readable dates

Hi I'm working in SAS platform and I've a data_set with more then 30 columns. there are two date columns in that data-set. dates in that data set are in format as 1.33E12 This is the little part of my table I want to create a new data-set with few…
Azeem112
  • 337
  • 1
  • 8
  • 23
-1
votes
1 answer

What is duration and how is it different to length? And why when a char variable with duration=1 is transformed to numeric, the duration becomes 8

What is the duration of a variable and how is it different to the length? And why when you use the input function to transform a char variable with duration=1 to numeric, the duration of the new numeric variable is 8? Ex. A string variable that…
Rhein Romer
  • 13
  • 1
  • 3
-1
votes
1 answer

SAS: How can i output a table that shows the column name, max length, and defined length of that column?

In SAS I'm trying to figure out how to get output (results or actual dataset) that show me the column name, var length, and max length (which would of course be repeated for each obs with that column name).
thepen
  • 1
-1
votes
1 answer

Breaking down multiple Left join in multiple steps in Proc Sql

I got a code that uses a lot of left join with many tables. When I run this code, it takes more than an hour to run and at the end it gives error with Sort Execution Failure. So, I am thinking of breaking down that left join in multiple steps but I…
shankar
  • 63
  • 1
  • 8
-1
votes
1 answer

PROC SQL/Variables within SAS Macro being ignored

I have the below macro, PARAMETERS, that assigns values to five variables and creates the table MD_WRK.SUB_ID. My issue is that the code within the macro worked fine until I placed it within the macro. Now the variables are not being populated and…
Matt Dixon
  • 11
  • 4
-1
votes
2 answers

Why Proc Sql is faster than Proc Summary for sum-function?

I have a column-based DB2-Blu table (DB2-Blu fixes indexing by itself) with 30.000 peer-groups and 50.000 values per peer group, total 1.5 billion rows. I did a test to compare the run-time with two different processes: Proc Summary and Proc Sql…
user3714330
  • 679
  • 12
  • 32
-1
votes
1 answer

why sas removing zero before a character

I have a proc sql like this one, the problem is that sas remove the zero before each cust_comp_key for example FR_C_00000242 is transforming to 242 but i want to keep the zeo before 242 ... rsubmit; data ca_m_service_2; set ca_m_service; num_compte…
Mostafa90
  • 1,674
  • 1
  • 21
  • 39
-1
votes
1 answer

Split a dataset into two new dataset based on percentage of split

I want to split by large dataset randomly into two new dataset in the ratio of 70% - 30%. Basically I need to allocate 70% of random values from large dataset to the newdataset1 and 30% of the random values from largedataset to the newdataset2. Can…
newbie49
  • 1
  • 2
-1
votes
2 answers

SAS - replicating the account numbers across the data

I have a data set like this: AcntNum name date 100 abc 12/01 abc2 12/02 abc3 12/03 101 abc4 12/04 abc5 12/05 abc6 12/06 I am trying to accomplish the below result dataset: Result: AcntNum name…
user2800204
  • 15
  • 1
  • 6
-1
votes
2 answers

Distinguish ID from start & end datetime

The first table contains Key-value & time like below Second Table contains each IDs have its start and end date. I'd like to find out ID for each row from time_stamp. There are fixed numbers of Categories. but there are a lot of ID. Would you…
Keith Park
  • 577
  • 1
  • 5
  • 16
1 2 3
52
53