sas

What does “variable = .” (variable = dot) mean in Oracle SQL/SAS?

守給你的承諾、 提交于 2020-06-08 12:29:12
问题 I am converting a SAS script to Python, where the SAS script was interfacing with an Oracle database, and the Python will be interfacing with a PostgreSQL database. In the SAS code, I found this statement: proc sql noprint; create table table_name as select distinct wtn from another_table where account = . ; What does "where account = ." mean in Oracle? Or is it not an Oracle SQL thing, and instead is a SAS thing? Or is it available in all forms of SQL? Further, if it is SAS and/or Oracle

SAS: Run SQL-query using a macro

会有一股神秘感。 提交于 2020-04-30 06:31:28
问题 Using an answer from this thread, I was trying to get to work the following code. I have a list of sql-queries in a table plus an id for each query. Now I'd like to have the results of these queries plus the id as another table. /* The Macro */ %macro run_query(q,id); proc sql noprint; select count into: count from (&q.) a; quit; %mend; /* Some fake-data */ DATA queries; INPUT id :$12. query :$3000.; INFORMAT id $12.; INFILE DATALINES DSD; DATALINES; 01,SELECT COUNT(*) AS count FROM sashelp

Replacing first row with values in second row

安稳与你 提交于 2020-04-16 03:56:05
问题 My dataset has missing values in the first row of every unique ID. I want to replace this first row with the values in the second row. My intuition tells me solution involves using _N_ and BY statement. My Data set: ID Var1 1 . 1 12 1 23 1 2 2 . 2 266 2 23 2 2 3 . 3 6 Result I am after: ID Var1 1 12 1 12 1 23 1 2 2 266 2 266 2 23 2 2 3 6 3 6 回答1: Use two SET statements. The second SET is for 'lead' processing (as opposed to 'lag'). The data set of the second set statement is the same as the

SAS Macro Truncating IDs

纵然是瞬间 提交于 2020-03-25 18:41:46
问题 I am using the ASA24 HEI SAS macro for the SAS University Edition. I believe SAS is truncating my IDs (ASA24 Usernames). In my data (.csv) I have Usernames like After the macro code, the GFHSp040x (x is a natural number) IDs get truncated to GFHSp040. Is this related to how the macro imports? Code below: /*The SAS program (HEI-2015 Individual Scores using multiple days of data from ASA24-2016 and ASA24-2018) ByPerson.SAS */ /*This SAS program can be used to calculate Healthy Eating Index (HEI

SAS Macro Truncating IDs

别说谁变了你拦得住时间么 提交于 2020-03-25 18:41:23
问题 I am using the ASA24 HEI SAS macro for the SAS University Edition. I believe SAS is truncating my IDs (ASA24 Usernames). In my data (.csv) I have Usernames like After the macro code, the GFHSp040x (x is a natural number) IDs get truncated to GFHSp040. Is this related to how the macro imports? Code below: /*The SAS program (HEI-2015 Individual Scores using multiple days of data from ASA24-2016 and ASA24-2018) ByPerson.SAS */ /*This SAS program can be used to calculate Healthy Eating Index (HEI

SAS sum observations not in a group, by group

霸气de小男生 提交于 2020-03-23 12:04:50
问题 I have a data set : data have; input group $ value; datalines; A 4 A 3 A 2 A 1 B 1 C 1 D 2 D 1 E 1 F 1 G 2 G 1 H 1 ; run; The first variable is a group identifier, the second a value. For each group, I want a new variable "sum" with the sum of all values in the column, exept for the group the observation is in. My issue is having to do that on nearly 30 millions of observations, so efficiency matters. I found that using data step was more efficient than using procs. The final database should

SAS sum observations not in a group, by group

喜欢而已 提交于 2020-03-23 12:04:38
问题 I have a data set : data have; input group $ value; datalines; A 4 A 3 A 2 A 1 B 1 C 1 D 2 D 1 E 1 F 1 G 2 G 1 H 1 ; run; The first variable is a group identifier, the second a value. For each group, I want a new variable "sum" with the sum of all values in the column, exept for the group the observation is in. My issue is having to do that on nearly 30 millions of observations, so efficiency matters. I found that using data step was more efficient than using procs. The final database should

SAS sum observations not in a group, by group

自作多情 提交于 2020-03-23 12:03:53
问题 I have a data set : data have; input group $ value; datalines; A 4 A 3 A 2 A 1 B 1 C 1 D 2 D 1 E 1 F 1 G 2 G 1 H 1 ; run; The first variable is a group identifier, the second a value. For each group, I want a new variable "sum" with the sum of all values in the column, exept for the group the observation is in. My issue is having to do that on nearly 30 millions of observations, so efficiency matters. I found that using data step was more efficient than using procs. The final database should

SAS macro for laboratory values

旧街凉风 提交于 2020-03-21 19:09:43
问题 I'm attempting to create a SAS macro that will generate a shift table for laboratory values. I have the following data: Study Subject Lab Measure Range Group Visit Study1 001 Lab1 45 Normal 1 Baseline Study1 001 Lab1 50 High 1 Visit2 Study1 001 Lab1 55 High 1 Visit3 Study1 002 Lab1 40 Normal 1 Baseline Study1 002 Lab1 44 Normal 1 Visit1 Study1 002 Lab1 45 Normal 1 Visit2 Study1 002 Lab1 46 Normal 1 Visit3 Study1 002 Lab1 52 High 1 Visit4 I'd like to create the following output: Final Lab

SAS proc export to CSV: how to add double quotes

隐身守侯 提交于 2020-03-21 16:29:19
问题 New to this, so apologies. I have a file in SAS that I need to export as a CSV and I need to add double quotes to all fields. How can I accomplish this? Thanks in advance. 回答1: There are many ways to create a CSV file from SAS. Using proc export won't wrap every field in double-quotes, so the easiest one that will do this is the %ds2csv() macro. This assumes you have SAS 9.2 or later. The documentation for it can be found here: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML