sas

create a macro only with macro variables creation (%let) in sas

﹥>﹥吖頭↗ 提交于 2019-12-25 18:00:28
问题 Hi I was trying to create a macro that only contains macro variable creation but it failed. Here is an example: %macro createvariable; %let a = 5; %let b = 6; %mend createvariable; %createvariable; data test; c = &a + &b; run; But it will work as: %macro createvariable; %let a = 5; %let b = 6; data test; c = &a + &b; run; %mend createvariable; %createvariable; So I was wondering if SAS won't be able to create a macro with only macro variables creation in it? Or there is a way to solve this

Email ID's from a SAS Dataset in Body

牧云@^-^@ 提交于 2019-12-25 16:57:26
问题 I'm trying to send out ID's of a SAS dataset in an email but not able to get the format right. I just need plain text as html is getting stuck and slow. Thanks in advance to help! Any one solution would be good. I have one ID column. The first solution one gives a complete list like %include "/saswrk/go/scripts/envsetup.sas"; filename mymail email "&emaillist." subject=" &env. Records Transferred on %sysfunc(date(),yymmdd10.)"; data null; set WORKGO.recds_processed; file mymail; put (_all_)(=

Format the summarised variables from proc summary

岁酱吖の 提交于 2019-12-25 16:09:39
问题 I'm using a Proc Summary, as I want to utilise a multilabel format. I've been going round and round trying to apply a format to my summarised outputs, but can't see how to get this without incurring warnings. Proc Summary Data = Source CompleteTypes Missing NoPrint NWay; Class Brand / MLF; Var Id Total; Output Out = Results N(ID) = Volume Sum(Total) = Grand_Total; Run; I want to format my Volume as Comma23. and the Grand_Total as Comma23.2. If I put a format statement after the outputs it

Format the summarised variables from proc summary

天大地大妈咪最大 提交于 2019-12-25 16:09:33
问题 I'm using a Proc Summary, as I want to utilise a multilabel format. I've been going round and round trying to apply a format to my summarised outputs, but can't see how to get this without incurring warnings. Proc Summary Data = Source CompleteTypes Missing NoPrint NWay; Class Brand / MLF; Var Id Total; Output Out = Results N(ID) = Volume Sum(Total) = Grand_Total; Run; I want to format my Volume as Comma23. and the Grand_Total as Comma23.2. If I put a format statement after the outputs it

how to put the name of a dataset as a column in SAS

风流意气都作罢 提交于 2019-12-25 14:03:40
问题 I have a very basic question in SAS. for example, if the dataset called 'a', how can I put 'a' as a new column into this dataset? Thank you very much 回答1: Basically you can't. You can make a new dataset. data new; set old; dsname='NEW'; run; You can use the INDSNAME option on the SET statement to tell you which dataset you are reading data from. data new ; length indsname dsname $41 ; set old indsname=indsname ; dsname = indsname ; run; Makes more sense when the SET statement has more than

SQL - Recursive Tree Hierarchy with Record at Each Level

混江龙づ霸主 提交于 2019-12-25 12:25:08
问题 Trying to do a classic hierarchy tree in SQL, using SAS (which does not support WITH RECURSIVE, so far as I know). Here's simplified data structure in existing table: |USER_ID|SUPERVISOR_ID| So, to build a hierarchy, you just recursively join it x number of times to get data you are looking for, where SUPERVISOR_ID = USER_ID . In my company, it is 16 levels. This issue comes when trying to get a branch to terminate for each user. For example, let's consider User A at level 1 has Users B,C,D,

Making the PROC MEANS statement in SAS produce a variable instead of a dataset

醉酒当歌 提交于 2019-12-25 10:01:57
问题 I need to obtain the sum of all the values in a column ("var1" in the code below). As far as I could determine, this is done as follows: proc means data = somedata sum var1; output out = sumtable sum = sum; run; The sum I want to use as a variable in the next step. Is it possible to have the OUTPUT statement above store the sum in a new variable instead of writing it to a whole new dataset? If so, what is the syntax for this? 回答1: In a word, no. You could store the value as a text string into

Retain variables for missing value [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-25 09:39:13
问题 This question already has answers here : An efficient way to Copying values in subsequent records - SAS (3 answers) Closed 4 years ago . Should be an easy question. I have a dataset like this: id mtna 1 . 2 . 3 1.7 4 . 5 . 6 5.2 7 9.6 8 . 9 . 10 . And I want something like this: id mtna 1 . 2 . 3 1.7 4 1.7 5 1.7 6 5.2 7 9.6 8 9.6 9 9.6 10 9.6 Basically just retain the pervious observation when there is a missing value. So I try something like this: data check; set check; retain lag_mtna; lag

Do loop - random number is generating the same number twice and isn't adding it in a running total

做~自己de王妃 提交于 2019-12-25 09:18:38
问题 Hey guys thank you so much, in advance, for your help! I have a data step before the code below called "simulation_tracking3", that outputs something like: CDFx Allowed_Claims .06 120 .12 13 .15 1400 My hash table averages the Allowed_Claims based on a randomly generated value (from 0 to 1). For example, let's call this Process A, if Px = rand('Uniform',0,1) yields .09, I want it to average between the Allowed_Claims values where Px = .06 and Px = 0.12, which is (120+13)/2 The role of the

SAS how to open most recent file when using Remote connection

妖精的绣舞 提交于 2019-12-25 08:33:45
问题 This is an extension from this question In Base SAS, how can I auto refresh the explorer? RawFocus gives me a way of opening a file but it doesn't work for me as I'm using rsubmit. The updated code initially didn't work, but now it opens the wrong file. v3 rather v7. As per this pic. The code I've used for the hotkey is as follows; dm 'keydef F4 "submit ''rsubmit; %nrstr(%sysrput lastDS=&syslast;) endrsubmit;''; vt rwork.%scan(&lastDS,2,.)"'; Any questions, please let me know, J 回答1: Had to