BookmarkSubscribeRSS Feed
ecampos2
Calcite | Level 5

Hello! I have a question, I have pre and post data from a survey... for each question there were multiple correct answers (for example 1 question had 5 answers [only 3 were correct] so I took the mean of each correct answers) 

now I have data that looks like :

ID PREPOST
1.50.75
2.251

 

So I imported the data on SAS and coded it like:

Proc compare data=work.import;
var _numeric_;
id id;
run;

proc ttest data=diff alpha=.05;
var _numeric_;
run;

 

and now its giving me the following error: 

ERROR 22-322: Syntax error, expecting one of the following: BASE, COMPARE, OUT, OUTSTATS.
ERROR 76-322: Syntax error, statement will be ignored.
 
and  ERROR: File WORK.DIFF.DATA does not exist.

 

12 REPLIES 12
PaigeMiller
Diamond | Level 26

Show us the whole LOG for PROC TTEST and PROC COMPARE, not selected parts. We need to see the code as it appears in the log for PROC TTEST and PROC COMPARE, plus all NOTEs, WARNINGs and ERRORs. Copy the log as text and then click the </> icon and paste the log into the window that appears. From now on (not in just this case), you need to do this every time you get an error in the LOG, no exceptions, do not wait until we ask to see the log, just do it following the instructions above.

 

2021-11-26 08_27_29-Reply to Message - SAS Support Communities — Mozilla Firefox.png

--
Paige Miller
ecampos2
Calcite | Level 5
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         /* Generated Code (IMPORT) */
 70         /* Source File: q_3 without.xlsx */
 71         /* Source Path: /home/u49754981/sasuser.v94 */
 72         /* Code generated on: 3/8/22, 11:06 AM */
 73         
 74         %web_drop_table(WORK.IMPORT6);
 NOTE: Table WORK.IMPORT6 has been dropped.
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              216.03k
       OS Memory           28068.00k
       Timestamp           03/08/2022 04:16:05 PM
       Step Count                        137  Switch Count  2
       Page Faults                       0
       Page Reclaims                     14
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 75         
 76         
 77         FILENAME REFFILE '/home/u49754981/sasuser.v94/q_3 without.xlsx';
 78         
 79         PROC IMPORT DATAFILE=REFFILE
 80         DBMS=XLSX
 81         OUT=WORK.IMPORT6;
 82         GETNAMES=YES;
 83         RUN;
 
 NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with 
       options MSGLEVEL=I.
 NOTE: The import data set has 41 observations and 10 variables.
 NOTE: WORK.IMPORT6 data set was successfully created.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              2801.12k
       OS Memory           30120.00k
       Timestamp           03/08/2022 04:16:05 PM
       Step Count                        138  Switch Count  2
       Page Faults                       0
       Page Reclaims                     538
       Page Swaps                        0
       Voluntary Context Switches        13
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 84         
 85         PROC CONTENTS DATA=WORK.IMPORT6; RUN;
 
 NOTE: PROCEDURE CONTENTS used (Total process time):
       real time           0.04 seconds
       user cpu time       0.04 seconds
       system cpu time     0.00 seconds
       memory              1774.84k
       OS Memory           28588.00k
       Timestamp           03/08/2022 04:16:05 PM
       Step Count                        139  Switch Count  0
       Page Faults                       0
       Page Reclaims                     93
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 86         
 87         
 88         %web_open_table(WORK.IMPORT6);
 89         
 90         Proc compare data=work.import6 noprint=diff;
                                                  _
                                                  22
                                                  76
 ERROR 22-322: Syntax error, expecting one of the following: BASE, COMPARE, OUT, OUTSTATS.  
 ERROR 76-322: Syntax error, statement will be ignored.
 91         var _numeric_;
 92         id id;
 93         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE COMPARE used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              487.96k
       OS Memory           28328.00k
       Timestamp           03/08/2022 04:16:05 PM
       Step Count                        140  Switch Count  0
       Page Faults                       0
       Page Reclaims                     66
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 94         
 
 
 95         proc ttest data=diff alpha=.05;
 ERROR: File WORK.DIFF.DATA does not exist.
 96         var _numeric_;
 97         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE TTEST used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              206.62k
       OS Memory           28068.00k
       Timestamp           03/08/2022 04:16:05 PM
       Step Count                        141  Switch Count  0
       Page Faults                       0
       Page Reclaims                     14
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 98         
 99         
 100        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 110        
PaigeMiller
Diamond | Level 26

There is no option NOPRINT=DIFF in PROC COMPARE.

 

I'm not even sure why you need to run PROC COMPARE, it's not required for PROC TTEST.

 

You probably want to use 

 

proc ttest data=work.import6 ...
--
Paige Miller
ecampos2
Calcite | Level 5

But when I try to just run the t test it doesn't allow me, in this case there were 4 different means (.25,.50,.75, or 1) does that make a difference? 

When I code for t test with dichotomous variables (1 or 0) I don't have this error 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         /* Generated Code (IMPORT) */
 70         /* Source File: q_3 without.xlsx */
 71         /* Source Path: /home/u49754981/sasuser.v94 */
 72         /* Code generated on: 3/8/22, 11:06 AM */
 73         
 74         %web_drop_table(WORK.IMPORT6);
 NOTE: Table WORK.IMPORT6 has been dropped.
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              218.59k
       OS Memory           28068.00k
       Timestamp           03/08/2022 04:45:12 PM
       Step Count                        147  Switch Count  2
       Page Faults                       0
       Page Reclaims                     14
       Page Swaps                        0
       Voluntary Context Switches        9
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 75         
 76         
 77         FILENAME REFFILE '/home/u49754981/sasuser.v94/q_3 without.xlsx';
 78         
 79         PROC IMPORT DATAFILE=REFFILE
 80         DBMS=XLSX
 81         OUT=WORK.IMPORT6;
 82         GETNAMES=YES;
 83         RUN;
 
 NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with 
       options MSGLEVEL=I.
 NOTE: The import data set has 41 observations and 10 variables.
 NOTE: WORK.IMPORT6 data set was successfully created.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              2812.40k
       OS Memory           30120.00k
       Timestamp           03/08/2022 04:45:12 PM
       Step Count                        148  Switch Count  2
       Page Faults                       0
       Page Reclaims                     539
       Page Swaps                        0
       Voluntary Context Switches        14
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 84         
 85         PROC CONTENTS DATA=WORK.IMPORT6; RUN;
 
 NOTE: PROCEDURE CONTENTS used (Total process time):
       real time           0.04 seconds
       user cpu time       0.04 seconds
       system cpu time     0.00 seconds
       memory              1744.71k
       OS Memory           28588.00k
       Timestamp           03/08/2022 04:45:12 PM
       Step Count                        149  Switch Count  0
       Page Faults                       0
       Page Reclaims                     93
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 86         
 87         
 88         %web_open_table(WORK.IMPORT6);
 89         
 90         proc ttest data=work.import6 alpha=.05;
 91          paired pre*post;
 ERROR: Variable Pre in list does not match type prescribed for this list.
 ERROR: Variable Post in list does not match type prescribed for this list.
 92         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE TTEST used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              462.96k
       OS Memory           28328.00k
       Timestamp           03/08/2022 04:45:12 PM
       Step Count                        150  Switch Count  0
       Page Faults                       0
       Page Reclaims                     48
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 93         
 94         
 95         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 105  
PaigeMiller
Diamond | Level 26

You are trying to use 

 

paired pre*post;

but both PRE and POST are character variables, can't be done with character variables, both PRE and POST must be numeric.

 

Somehow, you have created character variables where you should have numeric variables. So you need to change WORK.IMPORT6.

--
Paige Miller
ecampos2
Calcite | Level 5
how do I change character values, I already went back to excel and changed the format from "general" to "number" ?
PaigeMiller
Diamond | Level 26

@ecampos2 wrote:
how do I change character values, I already went back to excel and changed the format from "general" to "number" ?

We don't know because we don't have your data. Please provide a portion of your SAS data set that you are using (not the Excel file, which is irrelevant). Please follow these instructions to provide the data. Do not provide the data in any other format.

--
Paige Miller
Reeza
Super User
For the comparison you shouldn't do the summary, proc t-test or anova will do it, you want the raw data.
And you imported your data with Excel so you'll need to convert it - as mentioned on your other post.
ecampos2
Calcite | Level 5

I am not to familiar with coding with raw data that's why I first decode it on excel and then import it to SAS... In this case since we are testing for difference in means would you recommend that I use anova, t-test, or chi squared test? 

ecampos2
Calcite | Level 5

Thank you, I changed the variable to numeric values but I'm still getting the same error

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         /* Generated Code (IMPORT) */
 70         /* Source File: new Q3 without.xlsx */
 71         /* Source Path: /home/u49754981/sasuser.v94 */
 72         /* Code generated on: 3/8/22, 12:22 PM */
 73         
 74         %web_drop_table(WORK.IMPORT10);
 NOTE: Table WORK.IMPORT10 has been dropped.
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              300.03k
       OS Memory           27812.00k
       Timestamp           03/08/2022 05:35:55 PM
       Step Count                        210  Switch Count  2
       Page Faults                       0
       Page Reclaims                     14
       Page Swaps                        0
       Voluntary Context Switches        9
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 75         
 76         
 77         FILENAME REFFILE '/home/u49754981/sasuser.v94/new Q3 without.xlsx';
 78         
 79         PROC IMPORT DATAFILE=REFFILE
 80         DBMS=XLSX
 81         OUT=WORK.IMPORT10;
 82         GETNAMES=YES;
 83         RUN;
 
 NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with 
       options MSGLEVEL=I.
 NOTE: The import data set has 41 observations and 3 variables.
 NOTE: WORK.IMPORT10 data set was successfully created.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              2918.90k
       OS Memory           30120.00k
       Timestamp           03/08/2022 05:35:55 PM
       Step Count                        211  Switch Count  2
       Page Faults                       0
       Page Reclaims                     569
       Page Swaps                        0
       Voluntary Context Switches        15
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 84         
 85         PROC CONTENTS DATA=WORK.IMPORT10; RUN;
 
 NOTE: PROCEDURE CONTENTS used (Total process time):
       real time           0.03 seconds
       user cpu time       0.04 seconds
       system cpu time     0.00 seconds
       memory              1824.31k
       OS Memory           28588.00k
       Timestamp           03/08/2022 05:35:55 PM
       Step Count                        212  Switch Count  0
       Page Faults                       0
       Page Reclaims                     93
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           16
       
 
 86         
 87         
 88         %web_open_table(WORK.IMPORT10);
 89         
 90         proc ttest data=work.import10;
 91         
 92         paired pre*post;
 ERROR: Variable Pre in list does not match type prescribed for this list.
 ERROR: Variable Post in list does not match type prescribed for this list.
 93         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE TTEST used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              501.06k
       OS Memory           28328.00k
       Timestamp           03/08/2022 05:35:55 PM
       Step Count                        213  Switch Count  0
       Page Faults                       0
       Page Reclaims                     48
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 94         
 95         
 96         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 106        
ballardw
Super User

Your shown code does NOTHING to address the character variables. All it does is apparently reimport the same file resulting in the same type of values.

 

AFTER the proc import, LOOK at the data for the variables Pre and Post. As in, run proc contents to determine variable type.

If it shows type of Char, then they are character.

You will need to run a data step that has a chance of creating new data variables, likely using the "input" function. But without seeing actual values we have no way to tell.

 

You can try something like:

data work.totest;
   set work.import10;
   pre_num = input(pre, 8.);
   post_num= input(post, 8.);
run;

Likely you will have one or more messages about invalid data for those that cannot be turned into numbers, above code assumes your "number" has no more than 8 characters including a decimal place. If you think your values have more digits then increase the 8 to that length.

 

It may help to show the invalid data messages. Copy the log and paste in a text box as you have been.

 

Also, you can try using the Totest data set with proc Ttest.

 

Then notes in the import

NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with 
       options MSGLEVEL=I.

 makes me suspect one or more of the columns of the spreadsheet contains images. If they used some "image" for the values of Pre and Post you may have a serious issue with the data source.

Sajid01
Meteorite | Level 14

Hello @ecampos2 
It appears your data is in an excel sheet. You have difficulty in importing the raw data into SAS.
This being the case, consider performing the test in excel itself. You will get many resources on google.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 1352 views
  • 0 likes
  • 5 in conversation