sas

Quit vs Run statements in SAS

拜拜、爱过 提交于 2020-01-01 08:47:14
问题 In SAS, what is the difference between 'quit' and 'run'? statements? I cannot figure out when to use 'quit' and when to use 'run'? For example, why is proc datasets using quit but proc contents using run 回答1: This dates back to where SAS used to be a mainframe program (and still can be!). RUN; is a command for SAS to run the submitted statements. Back in the older mainframe days, statements would've been submitted to SAS one at a time (or in batches, but the core concept here is that each

Merge multiple tables in sas using loop or macro

那年仲夏 提交于 2019-12-31 07:06:10
问题 I have generated the tables of Forecast_2013 to 2022 in a loop and then merged all datasets in to 1 Table. But now I want to do merge the datasets in a loop with irrespective of years, The next year will be 2023 or 2024...I dont want to do mannually to set Forecast_2023;set forecast_2024. How can I put in to loop using macro? Data P_OT.FORECAST(DROP=td qq AGE1 AGE2 AGE3 AGE4 AGEBANDFCST020 AGEBANDFCST030 AGEBANDFCST035P HSI1_2012 HSI1_2013 HSI1_2014 HSI1_2015 HSI1_2016 HSI1_2017 HSI1_2018

How to replicate a SAS merge

自古美人都是妖i 提交于 2019-12-31 06:07:53
问题 I have two tables, t1 and t2: t1 person | visit | code1 | type1 1 1 50 50 1 1 50 50 1 2 75 50 t2 person | visit | code2 | type2 1 1 50 50 1 1 50 50 1 1 50 50 When SAS runs the following code: DATA t3; MERGE t1 t2; BY person visit; RUN; It generates the following dataset: person | visit | code1 | type1 | code2 | type2 1 1 50 50 50 50 1 1 50 50 50 50 1 1 50 50 50 50 1 2 75 50 I want to replicate this process in SQL, and my idea was to use a full-outer-join. This works unless there are duplicate

Macro that outputs table with testing results of SAS table

独自空忆成欢 提交于 2019-12-31 05:57:09
问题 Problem I'm not a very experienced SAS user, but unfortunately the lab where I can access data is restricted to SAS. Also, I don't currently have access to the data since it is only available in the lab, so I've created simulated data for testing. I need to create a macro that gets the values and dimensions from a PROC MEANS table and performs some tests that check whether or not the top two values from the data make up 90% of the results. As an example, assume I have panel data that lists

SAS data step view and data wrap in a macro for loop

流过昼夜 提交于 2019-12-31 05:28:07
问题 For a university research project I am retrieving data from WRDS via SAS and am relatively new to SAS. I am trying to retrieve data in a specific interval provided by WRDS which actually works very for me; the structure is as follows [1]Define some macro variable [2]Use data step view [3]Make manipulation on data [4]Export the data to csv In particular I am retrieving data for a stock for every single year. Instead of changing the variable all the time a macro that would allow me to provide

Want to create serial numbers

别来无恙 提交于 2019-12-31 05:22:23
问题 I want to generate the serial no.s e.g. I have, NID ----- ABD90 BGJ89 HSA76 and I want, ID NID --------- 1 ABD90 2 BGJ89 3 HSA76 What code should I run for this outcome? Please help me. 回答1: Since you tagged SAS, I'll answer with SAS. Based on your question, getting that result from that input would be as simple as this data result; ID=_N_; set input; run; or proc sql; select ID as monotonic() ,NID from input ; quit; In pure Oracle you would do this select rownum, NID from input However you

How to automate and import files that are located in date sequential folders into SAS?

流过昼夜 提交于 2019-12-31 04:12:08
问题 I currently have 700 folders that are all sequentially named. The naming convention of the folders are as follows:- 2011-08-15_2011-08-15 2011-08-16_2011-08-16 2011-08-17_2011-08-17 ... 2013-09-20_2013-09-20 There are 10 txt files within each folder that have the same naming convention. With the txt files all being the same, what I am trying to achieve is to automate the infile and then use the name of the folder, eg 2011-08-15_2011-08-15 or part of eg. 2011-08-15 to then be the name of the

Duration between two dates in SAS

馋奶兔 提交于 2019-12-31 01:48:06
问题 I will explain through an example- suppose I have two dates and I want to find the duration between them in years month date format start date= 19940412 end date= 20120326 duration of this 17 years 11 months 14 days. So what code do i write to get this result in sas? 回答1: Here's the code you need: data _null_; start_date= '19940412'; end_date= '20120326'; /* convert to sas dates */ start_dt=input(start_date,yymmdd8.); end_dt=input(end_date,yymmdd8.); /* calculate difference in years */ years

Using libname statement in 64 bit SAS to interact with 32 Excel

此生再无相见时 提交于 2019-12-31 00:45:37
问题 I have 64 bit SAS 9.4 installed and 32 bit Office 2007. When I had 32 bit SAS 9.3 installed, I was able to use a libname statement where the Excel file was the library and the "filename" that follows after the period was in fact a worksheet or named range in the Excel file. For example, you start with a libname statement libname exceltst path="C:\Users\username\Documents\test.xlsx"; And, then later you can reference a named range in this with exceltst.stuff, assume "stuff" is a named range.

SAS connection to Teradata Database using Teradata ODBC

烂漫一生 提交于 2019-12-30 11:09:47
问题 I'm trying to connect to Teradata in SAS. I set up an teradata ODBC on the machine. The assumption currently for me is that using ODBC is the only way for me to access the database. And here is the syntax of my connection command: Libname Teradata ODBC dsn = 'dsnname' uid = 'uid' pwd = 'pwd'; results: Error: The ODBC engine cannot be found. Error: Error in the LIBNAME statement. It keeps saying that the ODBC engine cannot be found. I'm really confused now. Is there anything wrong with the