sas

When using ods excel statement stop Excel converting numbers saved as character

送分小仙女□ 提交于 2021-02-11 13:31:39
问题 I need to export some results from SAS to Excel. So far, I was using a simple proc export for that but since the export got more complex (multiple proc result s and data sets need to be mapped to one sheet) I need to find an alternative. It seems, ods excel is the way to go - and I agree, it is highly customizable - but I am facing a problem where I am not sure whether it is SAS or Excel related. Problem: When I have a SAS data set with character columns, where the data are strings of digits

SAS: execute sql query strings out of a table?

雨燕双飞 提交于 2021-02-11 13:26:59
问题 If I have a table containing sql query strings like this (column query ) id query n ——————————————————————————————-————————————— 1 select count(*) from tab where x=... 2 select count(*) from tab where x=... ... In SAS is there a way to save the results of these queries in another column n ? 回答1: Just for fun - an approach using only proc sql: data queries; input id :8. query :$100.; infile datalines dsd; datalines; 1,select count(*) as count from sashelp.class where sex = 'F' 2,select count(*

SAS: execute sql query strings out of a table?

喜欢而已 提交于 2021-02-11 13:25:42
问题 If I have a table containing sql query strings like this (column query ) id query n ——————————————————————————————-————————————— 1 select count(*) from tab where x=... 2 select count(*) from tab where x=... ... In SAS is there a way to save the results of these queries in another column n ? 回答1: Just for fun - an approach using only proc sql: data queries; input id :8. query :$100.; infile datalines dsd; datalines; 1,select count(*) as count from sashelp.class where sex = 'F' 2,select count(*

ERROR: The ID value “xxxxxxxxxxxx” occurs twice in the same BY group. when transposing a complex dataset

纵然是瞬间 提交于 2021-02-11 13:17:56
问题 I have a strange data set and I am hoping you all can help me. I have a data set of the levels of certain environmental contaminants which are measured multiple ways along with the limit of detection are present in a group of research participants. I need these in a wide format, but unfortunately they are currently long and the naming conventions don’t easily translate. This is what it looks like now: ID Class Name Weight Amount_lipids Amount_plasma LOD 1 AAA Lead 1.55 44.0 10.0 5.00 1 AAB

SAS proc format statement

谁说我不能喝 提交于 2021-02-11 12:17:41
问题 I want to create a format on a numeric variable (say, age) to see the result as ">10". I tried as: PROC FORMAT; VALUE agefmt >10 - high = '> 10' /*10 to be excluded.*/ other = '<= 10' ; RUN; But it does not work. Please help. 回答1: You made just a small mistake, the > must be < and between the values: PROC FORMAT; VALUE agefmt 10 <- high = '> 10' /*10 to be excluded.*/ other = '<= 10' ; RUN; 来源: https://stackoverflow.com/questions/33346208/sas-proc-format-statement

Parse JSON object in SAS macro - Part 2 - using OUTPUT function to handle nested values

廉价感情. 提交于 2021-02-11 07:38:19
问题 This question is related to: prior question link I have a JSON file that looks like: [ { "rxnorm_id": "999999999", "drug_name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "plans": [ { "plan_id_type": "xxxxxxxxxxxxx", "plan_id": "999999999999999", "drug_tier": "xxxxxxxxxxxxxxx", "prior_authorization": false, "step_therapy": false, "quantity_limit": false }, I am able to import every line into SAS that has 'rxnorm_id and drug_name using this code: > filename data url 'http://stg-oh-medicaid

Parse JSON object in SAS macro - Part 2 - using OUTPUT function to handle nested values

我怕爱的太早我们不能终老 提交于 2021-02-11 07:37:21
问题 This question is related to: prior question link I have a JSON file that looks like: [ { "rxnorm_id": "999999999", "drug_name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "plans": [ { "plan_id_type": "xxxxxxxxxxxxx", "plan_id": "999999999999999", "drug_tier": "xxxxxxxxxxxxxxx", "prior_authorization": false, "step_therapy": false, "quantity_limit": false }, I am able to import every line into SAS that has 'rxnorm_id and drug_name using this code: > filename data url 'http://stg-oh-medicaid

Parse JSON object in SAS macro - Part 2 - using OUTPUT function to handle nested values

和自甴很熟 提交于 2021-02-11 07:36:10
问题 This question is related to: prior question link I have a JSON file that looks like: [ { "rxnorm_id": "999999999", "drug_name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "plans": [ { "plan_id_type": "xxxxxxxxxxxxx", "plan_id": "999999999999999", "drug_tier": "xxxxxxxxxxxxxxx", "prior_authorization": false, "step_therapy": false, "quantity_limit": false }, I am able to import every line into SAS that has 'rxnorm_id and drug_name using this code: > filename data url 'http://stg-oh-medicaid

How to format dates for use in SAS?

假如想象 提交于 2021-02-11 06:35:34
问题 I am trying to adapt Method 4 in this paper to calculate the duration of many observations, but discounting overlapping dates: https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/048-31.pdf For example, two rows of observations for subject 101 lasting from 2017-03-02 to 2017-03-16 and 2017-03-04 to 2017-03-17 respectively should return a value of only 16 days. I am getting an error with the dates being 'Invalid numeric data', though, resulting in later errors. I have tried

Drop observations once condition is met by multiple variables

笑着哭i 提交于 2021-02-10 23:28:36
问题 I have the following data and used one of the existing answered questions to solve my data problem but could not get what I want. Here is what I have in my data Amt1 is populated when the Evt_type is Fee Amt2 is populated when the Evt_type is REF1/REF2 I don't want to display any observations after the last Flag='Y' If there is no Flag='Y' then I want all the observations for that id (e.g. id=102) I want to display if the next row for that id is a Fee followed by REF1/REF2 after flag='Y' (e.g