sas

Outputting Regression results into a data frame in R

醉酒当歌 提交于 2020-01-04 02:06:07
问题 I was wondering if there is any command that can output the results of a lm model into a data frame in R like outest in SAS. Any ideas? I am running multiple models and I want the result to look like below - Model | alpha | Beta | Rsquared | F | df | model0 | 8.4 | ... | .... | ..| .. | model1 | ... | ... | .... | ..| .. | model2 | ... | ... | .... | ..| .. | The data i have is 'ds' which is - X1 | X2 | Y1 | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | .. | And my code is a simple

How to loop a logistic regression n number of times?

随声附和 提交于 2020-01-03 05:23:12
问题 I got a piece of code on SAS that predicts consumer behavior. So far I did 50 samples with 50 logistic regression by hand, but I'd like to automate this process. Steps are as follows: Create a table with all client having value "1" Create a table with all client having value "0" (below code starts here) Start a loop that: Get a sample of 3000 people from client having value "1" Get a sample of 3000 people from client having value "0" Join those two tables Logistic regression which should get

How can I find and replace specific text in a SAS data set?

▼魔方 西西 提交于 2020-01-02 21:56:59
问题 I have a data set with 400 observations of 4 digit codes which I would like to pad with a space on both sides ex. Dataset obs code 1 1111 2 1112 3 3333 . . . 400 5999 How can I go through another large data set and replace every occurrence of any of the padded 400 codes with a " ". ex. Large Dataset obs text 1 abcdef 1111 abcdef 2 abcdef 1111 abcdef 1112 8888 3 abcdef 1111 abcdef 11128888 ... Data set that I want ex. New Data set obs text 1 abcdef abcdef 2 abcdef abcdef 8888 3 abcdef abcdef

SAS: Print to Log AND View Live Log Window Simultaneously

六月ゝ 毕业季﹏ 提交于 2020-01-02 18:33:09
问题 I understand that PROC PRINTTO LOG="C:TEMP\SAS LOG.TXT" outputs the entire contents of a SAS program log, but this also essentially leaves the log window blank while the program is running and I am unable to view the 'live' progress of the SAS program so to speak. I want to ultimately save the log for further review, but I also want to keep an eye on things as they're happening live when I'm running tests, etc. -- is there a way to print the log and keep the contents of the log live as they

how to list all available user defined macros in SAS Enterprise Guide?

荒凉一梦 提交于 2020-01-02 05:43:05
问题 Say in my main code I have this code block: %macros hi5; %put hi five; %mend; %macros helloworld; %put hello world; %mend; How do I, in SAS Enterprise Guide, display something like this? (via log or via a SAS table) These are the user defined user macros: hi5 hello world (the aim is so that user is able to know what macros are already available to them). Note: the %put _ALL_ only list all macros variables, not macros (e.g. built with %macros and %mend .) 回答1: You can get there via PROC

single quoting values using sql to create macro variable

允我心安 提交于 2020-01-01 19:22:33
问题 I am using a macro in SAS to loop over the data tables in a specific library. I put the metadata information in a data null step and make a comparison with a where statement and my macro variable. My SQL step looks like: proc sql; select quote(trim(code)) into :procedures separated by ', ' from procedures; quit; Some values of code contain values like "45.10" and "G0102", so cannot be coerced to numeric. The macro contains the line: %macro filter_codes(indata, outdata); data &outdata; set

Lookup values in one table and add to dataset according to IF condition (MERGE/SQL)?

∥☆過路亽.° 提交于 2020-01-01 18:59:10
问题 I need to lookup data from one table and add it to a master data table based on an if condition: whether the data is flagged as missing. Say the lookup table contains countries and ports. There are missing port names in the master file that need to be filled. It fills these using the lookup only if flag = 1 (it's missing). This command doesn't work (won't fill it in & won't keep the obs with Flag =0): proc sql; create table data.varswprice1 as select * from data.varswprice a left join data

Proc sql: new and continue customers based on look back period

久未见 提交于 2020-01-01 17:10:12
问题 I have following data: wei 01feb2018 car wei 02feb2018 car wei 02mar2019 bike carlin 01feb2018 car carlin 05feb2018 bike carlin 07mar2018 bike carlin 01mar2019 car I want to identify new and continue customers, if a customer had no purchase in last 12 months then it will become a new customer. Required output be like wei 01feb2018 car new wei 02feb2018 car cont. wei 02mar2019 bike new carlin 01feb2018 car new carlin 05feb2018 bike cont. carlin 07mar2018 bike cont. carlin 01mar2019 car new Now

In Base SAS, how can I auto refresh the explorer?

穿精又带淫゛_ 提交于 2020-01-01 10:58:07
问题 I'm fairly sure this must be something that has bugged others and so there must be a solution. I write my code and want to quickly check the dataset, but it isn't there. I need to select the window, click View and click refresh. Is there a keyboard shortcut I can use or a macro I can write that does this for me? I know this is lazy but it bugs me. Any thoughts are appreciated. J 回答1: You could do this programmatically using: dm "next explorer; refresh"; Or assign it to a shortcut key (eg F2)

How can I create an ODBC connection to SAS?

白昼怎懂夜的黑 提交于 2020-01-01 09:23:45
问题 I'm writing a program that needs to access SAS data. I've downloaded the ODBC drivers for SAS and installed them, but I need to be able to create ODBC connections on the fly, programmatically. The following code (in Python) seems like it should work: import ctypes ODBC_ADD_DSN = 1 def add_dsn(name, driver, **kw): nul, attrib = chr(0), [] kw['DSN'] = name for attr, val in kw.iteritems(): attrib.append('%s=%s' % (attr, val)) return ctypes.windll.ODBCCP32.SQLConfigDataSource(0, ODBC_ADD_DSN,