BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
_maldini_
Barite | Level 11

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 DATA data_working_keep;
74 KEEP record_id provider_type___1-provider_type___14;
75 SET mchps.data_working;
76
77 array p provider_: ;
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
78 if sum(of p(*))=0 then call missing(of p(*));
79
80 LABEL
81 provider_type___1= "Medical Doctor (i.e. MD)"
82 provider_type___2 = "Osteopathic Doctor (i.e. DO)"
83 provider_type___3 = "Naturopathic Doctor (i.e. ND)"
84 provider_type___4= "Physicians Assistant (i.e. PA)"
85 provider_type___5= "Nurse Practitioner (i.e. NP)"
86 provider_type___6= "Registered Nurse (i.e. RN)"
87 provider_type___7= "Pharmacist (i.e. Rph)"
88 provider_type___8= "Massage therapist (i.e. LMP)"
89 provider_type___9 = "Acupuncturist (i.e. LA.c)"
90 provider_type___10= "Chiropractor (i.e. DC)"
91 provider_type___11 = "Clinical social worker (i.e. LCSW)"
92 provider_type___12 = "Physical therapist (i.e. PT)"
93 provider_type___13= "Psychiatrist"
94 provider_type___14= "Other";
95 RUN;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
78:15
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DATA_WORKING_KEEP may be incomplete. When this step was stopped there were 0 observations and 15
variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

Tom
Super User Tom
Super User

The error is saying that there are mixed types in the ARRAY then perhaps there are other variables in your dataset that have names that start with that prefix.  If you only want to keep some of the variables why are you bringing all of them into the data step?

SET mchps.data_working(KEEP=record_id provider_type___1-provider_type___14);

Also why are you making the ARRAY?  It is not needed for your code.

if sum(of provider_type___1-provider_type___14)=0 then 
  call missing(of provider_type___1-provider_type___14)
;

 

 

ballardw
Super User

@_maldini_ wrote:

@ballardw This is great. Thank you so much.

 

<I don't think you have stated what you want for percentage in the "total" of the last table.>

 

That's correct. I didn't. I don't think it makes sense because it sums to over 100%. You could manually assign a value such as 100 in the data step that creates the "Total" label OR the value of your wanted denominator / actual total respondents but that would likely require an explanation

 

For some reason, when I adapt your syntax to the overall dataset, there is a problem w/ the array (see syntax below): "All variables in array list must be the same type, i.e., all numeric or character."

 

A PROC CONTENTS shows that all the variables in the array ARE the same type - numeric. I don't understand arrays very well. Can you tell what I'm doing wrong?

 


If you have another variable in the actual data set that starts with Provider_ then the short cut will try to include that. Remember that your KEEP statement sets which variables go to the OUTPUT data set. All the other variables are on the data vector.

Likely the fix would be to explicitly list the variable range.

array p provider_type___1 - provider_type___14 ;

I don't allow my programs to create variables with multiple _ characters and was just avoiding typing them.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 3276 views
  • 11 likes
  • 5 in conversation