sas

SAS ODS Query/Statement print along with it's output

血红的双手。 提交于 2019-12-24 16:33:05
问题 SAS EG Is there any way I can print the query/statement used to get the output, along with the output, using SAS ODS? Suppose, ods pdf file=pdfile; proc sql; select a.* from tab1 a inner join tab2 b on a.something=b.something where <> having <>; quit; ods _all_ close; this would print the OUTPUT generated from the above query. But can I also get the query printed via the ods pdf along with the output? 回答1: There's no automatic way to redirect the log that I'm aware of. There are a few ways to

Error in data set firstobs

不羁的心 提交于 2019-12-24 15:05:32
问题 I am very, very new to SAS and have been reading stackoverflow questions and SAS documentation, to write code for a very specific purpose. I have been having a hard time achieving my goal and understanding SAS for two reasons: I can only execute code on a remote server though SSH because I do not have SAS locally (so, on every change, I need to upload the file, execute and get the log and lst files back, check for errors) and most of the introductory topics I have read about are not

Converting character variabls to numeric in SAS

纵然是瞬间 提交于 2019-12-24 14:55:02
问题 I am creating a numeric version of a character variable in SAS. I am using the best32. numeric format along with an input statement, as I do not want to lose any data. Below is an example that in which SAS is dropping data and I am unclear as to why. DATA trial; X='1264263.336532'; Y=INPUT(X,BEST32.); PUT Y; RUN; Y is only 1264263.3365 and not X. I am unsure why this is happening. 回答1: SAS is displaying the number in the default BEST12. format. Try PUT Y best32.; instead 来源: https:/

How to make a SAS DIS job loop over rows of a parameter table

允我心安 提交于 2019-12-24 14:14:42
问题 I have a SAS DIS job which extracts and processes some timestamped data. The nature of the job is such that the data must be processed a bit at a time, month by month. I can use a time filter to ensure any given run is within the required timeframe, but I then must manually change the parameters of that table and rerun the job, month by month, until all the data is processed. Since the timeframes extend back quite far, I'd like to automate this process as much as possible. Ideally I'd have a

SAS Macro for multiple datasets

我的梦境 提交于 2019-12-24 13:43:18
问题 I am new to SAS. I have 12(Monthly data) data sets in a folder. Names of data sets are: 201401 201402 201403 ... 201411 201412 Each data contain 10 Variables. Variable names are same for all data. I want only 3 Variables among 10 and rename data by new_201401 and so on. I am trying it manually by using Keep Var1 Var2 Var3; but is there any easy way or macro so we can make it fast? Thanks in advance. 回答1: I think this will do the trick: %macro keep(table,var1,var2,var3,set); data &table (keep=

What SAS modules do I need to run my code?

可紊 提交于 2019-12-24 13:43:15
问题 I have a large collection of SAS programs. Currently, I have lots of SAS modules licensed and installed (I've checked which ones via %sasinstallreporter), but I'm not sure whether I need all of them. How can I determine which modules I actually need in order to run all of my code? They're rather expensive and I don't want to pay for modules that I'm not going to use. Is there a list of procs / libname engines somewhere that are tied to specific SAS modules? Apologies if this is a duplicate,

SAS Macro function conditional on value of Macro Variable

*爱你&永不变心* 提交于 2019-12-24 13:05:14
问题 I have a SAS project (EGv7.1) that allows the user to specify a value on the first line. Then, other processes are invoked based on the value specified. One of these is that some other macro variables are assigned. Below is what I have, and it does not seem to be working. I really need the let statement to be first in the sequence, but besides that I am open to changes. Any suggestions? %let number=8; %macro my_function(); %if &number=8 %then %do; %let number_text=eight; %let number_text_2

SAS: how to use the table column with special character $

末鹿安然 提交于 2019-12-24 12:57:18
问题 I use sas manipulate some database tables. There is a column "CDR$UNPIVOT$SKEY" in one table. I can't direct use this column name in data step or Proc SQL, even i change the option of VALIDVARNAME=ANY. Is there a way to direct use such column name? Thank you! 回答1: Yep. You are very close now. All you need is to address it using its literal format. option validvarname=any; data want; 'CDR$UNPIVOT$SKEY'n = 'I can see now'; run; proc print data=want;run; 来源: https://stackoverflow.com/questions

Count rows number by group and subgroup when some subgroup factor is 0

末鹿安然 提交于 2019-12-24 12:42:25
问题 I know how to count group and subgroup numbers through proc freq or sql. My question is when some factor in the subgroup is missing, and I still want to show missing factor as 0. How can I do that? For example, the data set is: group1 group2 1 A 1 A 1 A 1 A 2 A 2 B 2 B I want a result as: group1 group2 N 1 A 4 1 B 0 2 A 1 2 B 2 If I only use the default SAS setting, it will usually show as group1 group2 N 1 A 4 2 A 1 2 B 2 But I still want to the second line in the result tell to me that

How to get same results of Wilcoxon sign rank test in R and SAS

可紊 提交于 2019-12-24 12:31:09
问题 R code: x <- c(9, 5, 9 ,10, 13, 8, 8, 13, 18, 30) y <- c(10, 6, 9, 8, 11, 4, 1, 3, 3, 10) library(exactRankTests) wilcox.exact(y,x, paired = TRUE, alternative = "two.sided") The results: V = 3, p-value = 0.01562 SAS code: data aaa; set aaa; diff=x-y; run; proc univariate; var diff; run; The results: S=19.5 Pr >= |S| 0.0156 How to get statistics S in R? If n<=20 the exact P was same in SAS and R,but if n>20 the results were different. x <- c(9, 5, 9 ,10, 13, 8, 8, 13, 18, 30,9, 5, 9 ,10, 13, 8