sas

Proc SQL: How / When does SAS Move the Data

痴心易碎 提交于 2019-12-24 05:26:07
问题 I am a DBA / R user. I just took a job in an office full of SAS users and I am trying to understand better how SAS' proc sql works. I understand that SAS includes a relational database and it includes the ability to run proc sql against external servers like Oracle. I am trying to better understand when / how it decides to use the database server rather than its internal database system. I have seen some really S. L. O. W. SAS code where my coworkers running a series of proc sql commands.

Error in loading package SASxport: object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

依然范特西╮ 提交于 2019-12-24 05:25:11
问题 I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this: library("Hmisc") sasxport.get("C:/path/file.XPT") and library("SASxport") read.xport("C:/path/file.XPT") The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport") , I get the error message:

By group processing in SAS

我与影子孤独终老i 提交于 2019-12-24 05:12:06
问题 I have a very large table with an indexed datetime field. I want to do by group processing on the dataset by month and only output the last observation in each month. The problem is that it doesn't contain a month field so I can't use something like this: if last.month then do; output; end; Is there a way I can achieve this kind of behaviour without having to add a month field in a previous datastep? The table is 50 gig compressed so I want to avoid any unnecessary steps. Thanks 回答1: You can

By group processing in SAS

蓝咒 提交于 2019-12-24 05:12:05
问题 I have a very large table with an indexed datetime field. I want to do by group processing on the dataset by month and only output the last observation in each month. The problem is that it doesn't contain a month field so I can't use something like this: if last.month then do; output; end; Is there a way I can achieve this kind of behaviour without having to add a month field in a previous datastep? The table is 50 gig compressed so I want to avoid any unnecessary steps. Thanks 回答1: You can

how to pass a string to a macro sas without special char

↘锁芯ラ 提交于 2019-12-24 03:55:26
问题 I wrote this macro in sas to have some information about some files : %macro info_1(cmd); filename dirList pipe &cmd.; data work.dirList; infile dirList length=reclen; input file $varying200. reclen; permission=scan(file,1,""); if input(scan(file,2,""), 8.)=1; user=scan(file,3,""); group=scan(file,4,""); file_size_KB=round(input(scan(file,5,""), 8.)/1024,1); file_size_MB=round(input(scan(file,5,""), 8.)/1024/1024,1); modified_time=input(catx(" ",scan(file,6," "),scan(file,7,"")),anydtdtm.);

Prompting for SAS ODBC connection password when running in batch mode

时间秒杀一切 提交于 2019-12-24 03:45:17
问题 For various reasons I prefer to run my SAS programs in batch mode as much a possible. And for security reasons I'd prefer to have SAS prompt me for a password whenever making and ODBC connection to a Teredata warehouse. Can I have both of these things at once? The following code works fine when run from SAS interactively, but won't create a prompt when run in batch. proc sql; connect to odbc (prompt); quit; Anyone know of a way make this work? (Also, I'm looking for a solution specifically

Rearranging variables in a sas dataset- alphabetical order

我怕爱的太早我们不能终老 提交于 2019-12-24 03:26:12
问题 I have like 500 columns of dataset, and I want to rearrange all the variables in an alphabetical order. How can I do that in any other way than using retain statement before set statement? 回答1: You can generate the list of variable names dynamically, and create a new dataset using PROC SQL . proc sql ; select name into :VARLIST separated by ', ' from dictionary.columns where libname = 'SASHELP' and memname = 'CLASS' order by name ; quit ; proc sql ; create table ordered as select &VARLIST

Defining a calculated member in MDX - filtering a measure's value

此生再无相见时 提交于 2019-12-24 02:13:07
问题 I need to define a calculated member in MDX (this is SAS OLAP, but I'd appreciate answers from people who work with different OLAP implementations anyway). The new measure's value should be calculated from an existing measure by applying an additional filter condition. I suppose it will be clearer with an example: Existing measure: "Total traffic" Existing dimension: "Direction" ("In" or "Out") I need to create a calculated member "Incoming traffic", which equals "Total traffic" with an

SAS replace character in ALL columns

◇◆丶佛笑我妖孽 提交于 2019-12-24 01:45:45
问题 I have a SAS dataset that I have to export to a .csv-file. I have the following two contradicting requirements. I have to use the semicolon as the delimiter in the .csv-file. Some of the character variables are manually inputted strings from formulas, hence they may contain semicolons . My solution to the above is to either escape the semicolon or to replace it with a comma. How can I, in a nice, clean and efficient way use e.g. tranwrd on an entire dataset? My attempt: For each variable, use

Cleaner way of handling addition of summarizing rows to table?

烂漫一生 提交于 2019-12-24 01:24:36
问题 I have a dataset that is unique by 5 variables, with two dependent variables. My goal is for this dataset to have appended to it additional rows with TOTAL as the value of independent variables, with the values of the dependent variables changing accordingly. To do this for a single independent variable is not a problem, I would do something along the lines of: proc sql; create table want as select "TOTAL" as independent_var1, independent_var2, ... independent_var5, sum(dependent_1) as