sas

Keeping or deleting a group of observations based on a characteristic of a BY-group

风流意气都作罢 提交于 2019-12-25 08:13:10
问题 I answered a SAS question a few minutes ago and realized there is a generalization that might be more useful than that one (here). I didn't see this question already in StackOverflow. The general question is: How can you process and keep an entire BY-group based on some characteristic of the BY-group that you might not know until you have looked at all the observations in the group? Using input data similar to that from the earlier question: * For some reason, we are tasked with keeping only

Blob fields in SAS gets truncated

坚强是说给别人听的谎言 提交于 2019-12-25 07:35:03
问题 I have been working on a SAS job that extracts a table from SQL server and then loads that table to an Oracle table. One of the fields there in SQL server is blob and they can be as big as 1G. I am getting length warnings when I run this blobs on oracle table seems to be truncated and as a result files there are corrupt. I have seen SAS stating that character variable can be max 32K but SAS also states it can access blobs up to 2G. How can we achieve that? proc sql; create view work.W2K3NU8

Creating prompt for missing and nonmissing

纵饮孤独 提交于 2019-12-25 07:08:57
问题 I am trying to add prompt for missing or nonmissing options. This code doesn't work ,need to fix that. rec_And_issues is a new table that I created in the report. Need to pick rec_and_issues.SFVFDBK_FEEDBACK_COMMENTS is missing or not. %macro missing_or_nonmissing; %if "&sel_issue" eq "Missing" %then %do; DATA rec_and_issues; set rec_and_issues; rec_and_issues.SFVFDBK_FEEDBACK_COMMENTS is null; run; %end; %else %if "&sel_issue" eq "NonMissing" %then %do; DATA rec_and_issues; set rec_and

How to create a truncated permanent database from a larger file in SAS [duplicate]

醉酒当歌 提交于 2019-12-25 04:44:07
问题 This question already has answers here : Read specific columns of a delimited file in SAS (3 answers) Closed 4 years ago . I'm trying to read a comma delimited .txt file (called 'file.txt' in the code below) into SAS in order to create a permanent database that includes only some of the variables and observations. Here's a snippet of the .txt file for reference: SUMLEV,REGION,DIVISION,STATE,NAME,POPESTIMATE2013,POPEST18PLUS2013,PCNT_POPEST18PLUS 10,0,0,0,United States,316128839,242542967,76.7

SAS/PROC SQL - remove ALL observations in BY group as long as there are duplications (not just remove the duplications)

随声附和 提交于 2019-12-25 04:31:28
问题 I am new to SAS and I am trying to remove groups if they fulfil two conditions. I currently have this data set: ID ID_2 ID_3; A 1 1; A 1 1; A 1 1; A 2 0; A 2 1; B 3 0; B 3 0; I am grouping by ID then by ID_2 . I want to remove ALL entries in the by groups as long as (1) there exists duplication across all three variables - I don't just want to remove the duplicates, I would like to remove the entire group AND (2) this duplication involves value '1' in ID_3 across all rows in each by group. In

SAS/PROC SQL - remove ALL observations in BY group as long as there are duplications (not just remove the duplications)

早过忘川 提交于 2019-12-25 04:31:14
问题 I am new to SAS and I am trying to remove groups if they fulfil two conditions. I currently have this data set: ID ID_2 ID_3; A 1 1; A 1 1; A 1 1; A 2 0; A 2 1; B 3 0; B 3 0; I am grouping by ID then by ID_2 . I want to remove ALL entries in the by groups as long as (1) there exists duplication across all three variables - I don't just want to remove the duplicates, I would like to remove the entire group AND (2) this duplication involves value '1' in ID_3 across all rows in each by group. In

SAS proc sql with when then statements

时光怂恿深爱的人放手 提交于 2019-12-25 03:35:34
问题 I have a "time" var of years in my data. I need to create a new var based on the following with PROC SQL if time>mean(time)then new var=1 else, new var=0 I keep getting different error, how can I improve my code? proc sql; create table v3 as select*,case when time>mean(time)then time_group=1 else time_group=0 as time_group,* from v2; quit; 回答1: You're nearly there: proc sql ; create table v3 as select *, case when time>mean(time) then 1 else 0 end as time_group from v2; quit; 回答2: There are

SAS proc sql with when then statements

折月煮酒 提交于 2019-12-25 03:35:19
问题 I have a "time" var of years in my data. I need to create a new var based on the following with PROC SQL if time>mean(time)then new var=1 else, new var=0 I keep getting different error, how can I improve my code? proc sql; create table v3 as select*,case when time>mean(time)then time_group=1 else time_group=0 as time_group,* from v2; quit; 回答1: You're nearly there: proc sql ; create table v3 as select *, case when time>mean(time) then 1 else 0 end as time_group from v2; quit; 回答2: There are

SAS date conversion from text.

梦想与她 提交于 2019-12-25 03:28:22
问题 Hi I have a date conversion problem in SAS, I imported an excel file which has the following dates., 2012-01-09 2011-01-31 2010-06-28 2005-06-10 2012-09-19 2012-09-19 2007-06-12 2012-09-20 2004-11-01 2007-03-27 2008-06-23 2006-04-20 2012-09-20 2010-07-14 after I imported the dates have changed like this 40917 40574 40357 38513 41171 41171 39245 41172 38292 39168 39622 38827 41172 40373 I have used the input function to convert the dates but it gives a strange result., the code I used., want

Reading the file folder on UNIX using SAS

拟墨画扇 提交于 2019-12-25 03:26:21
问题 I am trying to read the folder with zip files using Pipe Command. But I get error saying ls command not recognized. There are actually 2 zip files(ABC_*.zip) in the folder /PROD/ Can anybody help me in this? %let extl_dir=/PROD/ ; filename zl pipe "ls &extl_dir.ABC_*.zip"; data ziplist_a; infile zl end=last; length path $200 zipnm $50 filedt $15; input path $; zipnm=scan(path,-1,"/"); filedt=scan(scan(path,-1,"_"),1,"."); call symput('zip'||left(_n_), zipnm); call symput('path'||left(_n_),