sas

SAS importing dates from excel

↘锁芯ラ 提交于 2020-01-30 03:27:48
问题 I have an xlsx dataset that I import using proc import. There is a column in excel that holds date values like: 2018-11-30 00:00:00 When I import it into SAS it automatically converts it into a number 43434. When I try to cast this to a date: put(col,date9.), i get: 2078-12-01 What is happening? How can I get back the correct date. I tried mixed=yes option but it does not work with dbms=xlsx. When i do dbms=excel, it does not work as expected 回答1: Sometimes SAS imports the date as a raw Excel

Using first.variable and last.variables with accumulator variables

拈花ヽ惹草 提交于 2020-01-26 04:08:25
问题 I am trying to understand what this program does. data a; set b (keep=c d); by c; if first.c then e=0; e+d; if last.c; run; What confuses me is the following. 1), When there is not THEN statements, what does and IF statement do? 2), When there is no value evalueated, what does an IF statement do ? (why would it not say something like if first.c =1 ?) 3), My understanding is that e is an accumulator variable starting from 0, and d is added by iteration. But for some reason e represents the

How do I perform regression by month on the same SAS data set?

时间秒杀一切 提交于 2020-01-25 16:21:06
问题 My specification is as follows: Proc reg data = liqfworld; Model x = y z ; I need to perform this regression for every stock in my data set which has daily data and for every month. It is sorted by stock ID and dates in SAS format. Do I need a macro for performing repeated regressions on the same data set? My ultimate aim is to obtain the coefficient for y for each stock and each month into an output data set. Grateful for any pointers. Thanks. EDIT: To clarify, I need to do multiple not

How do I perform regression by month on the same SAS data set?

核能气质少年 提交于 2020-01-25 16:18:15
问题 My specification is as follows: Proc reg data = liqfworld; Model x = y z ; I need to perform this regression for every stock in my data set which has daily data and for every month. It is sorted by stock ID and dates in SAS format. Do I need a macro for performing repeated regressions on the same data set? My ultimate aim is to obtain the coefficient for y for each stock and each month into an output data set. Grateful for any pointers. Thanks. EDIT: To clarify, I need to do multiple not

Transpose dataset in Hive

我的未来我决定 提交于 2020-01-25 07:58:48
问题 I'm trying to transpose a variable in Hive such as: Id1 Id2 Event 1 1 7 2 2 3 2 2 7 to Id1 Id2 Event_7 Event_3 1 1 1 2 2 1 1 Following is what I have so far: create temporary table event_trans as select Id1, Id2,Event kv['3'] as Event_3, kv['7'] as Event_7 from( select Id1, Id2, collect(Event, '1') as kv from event1 group by Id1, Id2 )t Error: Error while compiling statement: FAILED: ParseException line 1:84 missing EOF at '[' near 'kv' I'm also interested to know how to transpose a dataset

sas drop value through the whole data

試著忘記壹切 提交于 2020-01-25 07:09:09
问题 I want to turn invalid values to a single value and them print only the ID's of the obs that has these values=> I have multiple error is the second part (the loop), is it possible to fix somehow this code, or is it simply impossible to do that this way? data comb8;set comb; if q2 not in (1,2,3,4,5)then q2=666; if q3 not in (1,2,3,4,5)then q3=666; if q10 not in (1,2,3,4,5)then q10=666; if gender not in(0,1)then gender=666; if married not in(0,1)then married=666; run; data comb10; set comb8; do

SAS: sort error (by variable not sorted properly)

亡梦爱人 提交于 2020-01-25 00:06:25
问题 This question is a follow up from another I had here SAS: Data step view -> error: by variable not sorted properly; I am opening a new question as the desired solution is slightly different: As I am looping through several input files, one of the raw-files is not properly sorted, I wonder what I could do to make my program to skip that particular input file and just continue? Quote: I am using a macro to loop through files based on names and extract data which works fine for the majority of

Writing SAS dates to SQL Server databse

时光毁灭记忆、已成空白 提交于 2020-01-24 22:20:13
问题 How to write SAS dates to Microsoft SQL Server 2016 Date data type in database? I got SAS data with a sas date DataEndDay and I want to write that into a database. The following bit is in use (buffer is just to speed up the testing-failing) : libname valu oledb provider=sqloledb schema="dbo" INSERTBUFF=100 properties=("User ID"="&username." Password="&pw." "data source" = &database. "initial catalog"=&catalog.); proc sql noprint; insert into valu.Data_upload_from_me ( <some_columns...>, <more

Set the labels of a SAS Dataset equal to their variable name

我与影子孤独终老i 提交于 2020-01-24 15:22:23
问题 I'm working with a rather large several dataset that are provided to me as a CSV files. When I attempt to import one of the files the data will come in fine but, the number of variables in the file is too large for SAS, so it stops reading the variable names and starts assigning them sequential numbers. In order to maintain the variable names off of the data set I read in the file with the data row starting on 1 so it did not read the first row as variable names - proc import file="X:\xxx\xxx