- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi I'm new to coding HCUP data in SAS. I am using ICD10 codes but it seems, but it seems like SAS is not accepting the characters. For instance the variable name is |10_DX1 but I get an error message any time that I use it. I am looking for ICD 10 codes specific to deliveries. The code below doesn't seem to work. How to I find ICD10 codes specific to deliveries? I am using SAS v9.4 on JupyterLab.
data = NY2016_deliveries;
set NY2016;
delivery_flag = 0;
array dx_vars {*} DX1-DX25;
do i = 1 to dim (dx_vars);
if substr(dx_vars[i], 1, 3) in;
('O60', 'O61',)
delivery_flag=1;
leave;
end;
end;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ALWAYS post the log when you have issues.
This looks wrong:
data = NY2016_deliveries;
A DATA statement does not have an equal sign apart from those needed in additional options.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data NY2016_deliveries;
set NY2016;
length delivery_flag dxpos 3 dx $10;
delivery_flag = 0;
dxpos=.;
dx=' ';
array dx_vars {*} DX1-DX25;
do i = 1 to dim(dx_vars);
if substr(dx_vars[i], 1, 3) in ('O60', 'O61') then do;
delivery_flag=1;
dxpos=i;
dx=dx_vars[i];
output;
leave;
end;
end;
drop i dx1-dx-25;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It would be very good idea that when posting code related to problems to post a log of the complete step in question. That means for a data step question start at Data and stop with the notes, warnings and or error messages at the end. For a procedure start at the Proc statement.
That means we don't have to ask questions like "Is the syntax of the DROP statement you show actually what you submiited?"
data NY2016_deliveries; set NY2016; length delivery_flag dxpos 3 dx $10; delivery_flag = 0; dxpos=.; dx=' '; array dx_vars {*} DX1-DX25; do i = 1 to dim(dx_vars); if substr(dx_vars[i], 1, 3) in ('O60', 'O61') then do; delivery_flag=1; dxpos=i; dx=dx_vars[i]; output; leave; end; end; drop i dx1-dx-25; run;
Your code as shown does not execute at all it would throw
17 drop i dx1-dx-25; - 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored.
Including all the notes and messages would also provide answers to the problems that will arise if any of the DX1 through DX25 variables are numeric.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ballardw - yup, that one was my mistake (in the DROP statement) - obv. should be: ...-dx25 rather than: ...-dx-25.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This seemed to work:
data SCDNY2016_deliveries;
set scdny2016;
length delivery_flag dxpos 3 dx $10;
delivery_flag = 0;
dxpos=.;
array dx_vars {*} I10_DX1-I10_DX25;
do i = 1 to dim(dx_vars);
if substr(dx_vars[i], 1, 3) in ('O60', 'O61') then do;
delivery_flag=1;
dxpos = i;
dx = dx_vars[i];
output;
leave;
end;
end;
drop i;
run;
proc print data=SCDNY2016_deliveries (obs=10); /*checking the first 10 observations*/
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tried a different approach. The variable name for ICD 10 codes is |10_DX1-|10_DX25. However SAS doesn't accept the | character so I am not sure how to proceed but I tried another way here's the log with error messages:
data scdny2016_delivery;
set scdny2016;
delivery_flag = 0;
array dx_vars {*}
I10_DX1 I10_DX2 I10_DX3 I10_DX4 I10_DX5
I10_DX6 I10_DX7 I10_DX8 I10_DX9 I10_DX10
I10_DX11 I10_DX12 I10_DX13 I10_DX14 I10_DX15
I10_DX16 I10_DX17 I10_DX18 I10_DX19 I10_DX20
I10_DX21 I10_DX22 I10_DX23 I10_DX24 I10_DX25;
do i = 1 to dim(dx_vars);
if substr(dx_vars[i], 1, 3) in
('O60', 'O61', 'O62', 'O63', 'O64', 'O65', 'O66', 'O67', 'O68', 'O69',
'O70', 'O71', 'O72', 'O73', 'O74', 'O75', 'O76', 'O77', 'O78', 'O79',
'O80', 'O81', 'O82', 'Z37', 'Z38') then do;
delivery_flag = 1;
leave;
end;
end;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It's very unlikely that you have variables names with a in them, like: I10_DX1
If you run PROC CONTENTS on your data and look at the list of variables, you see | characters there in the variable name?
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Why do you think the variable name is |10_DX1 ? I really doubt that HCUP would name a variable that way.
If you do have non-standard variable names you need to use name literals when referencing them in your SAS code.
'|10_DX1'n
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yea, I thought it was weird too but changed the character from | to I (uppercase i) and it seems to have worked