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

Hi,

 

I create a SAS report using the DATA step with my code below. In the report, I want to recode the value of -8.00 to a dash

' - ' to indicate no observations. Below is a portion of the report. How can I do that in SAS?

 

Thanks

 

DATA SCORED.&FORM.Combined_Statistics_R;

SET SCORED.&FORM.Combined_Statistics_R (RENAME=(Key_char=Key));

file print header=H notitles;

PUT @1 "Item Number:" @14 seq @20 "Accession Number:" @38 ACN @55 "N of Response Opts:" @75 Number_of_Options/

@4 "Correct Answer:" @20 Key/

@4 'P value:' @13 pvalue @21 'Pt Biserial:' @34 Pt_Biserial @42 "Bench Item Delta:" @60 Bench_Item_Delta //

@10 'Response Opt:' @26 "A" @36 "B" @46 "C" @56 "D" @66 "E" @76 'Total N of PPL'/

@10 'N of PPL:' @26 N_of_ppl_A @36 N_of_ppl_B @46 N_of_ppl_C @56 N_of_ppl_D @66 N_of_ppl_E @76 Total_N/

@10 'P Value:' @26 PValue_A @36 PValue_B @46 PValue_C @56 PValue_D @66 PValue_E/

@10 'Pt Biserial:' @26 PT_Biserial_A @36 PT_Biserial_B @46 PT_Biserial_C @56 PT_Biserial_D @66 PT_Biserial_E/

@10 'Mean Score:' @26 Mean_Score_A @36 Mean_Score_B @46 Mean_Score_C @56 Mean_Score_D @66 Mean_Score_E////;

return;

H: Put @1 "Item analysis for &FORM that has &NUMBER MCQs."////;

RUN;

 


 

Item analysis for Exam_1922 that has 120 MCQs.                                                                                                                      
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    
                                                                                                                                                                    
         Response Opt:   A         B         C         D         E         Total N of PPL                                                                           
         N of PPL:       0         0         0         1         365       367                                                                                      
         P Value:        0.000     0.000     0.000     0.003     0.995                                                                                              
         Pt Biserial:    -8.00     -8.00     -8.00     -.059     0.078                                                                                              
         Mean Score:     0.000     0.000     0.000     63.00     77.31            
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

A few steps are required;  First, before the DATA step:

 

options missing='-';

 

You can change the -8 to missing, but still need this statement to get it to print as a dash.  After the DATA step is over, you can consider whether or not you want to reset with:

 

options missing='.';

 

Next, in the DATA step (right after the SET statement), you need to transform your data.  This means first collecting all the variables that might need to be changed:

 

array eights {*} PT_Biserial_:;

 

You can add to the list if more variables belong there.

 

Then immediately change the values before the PUT statement writes them out:

 

do i=1 to dim(eights);

   if eights{i}=-8 then eights{i}=.;

end;

 

That should do it.

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

A set of conditionals after the set:

if <variable>=-0.800 then <variable>="-";

However if they are numeric values then you cant just put dashes in as it has to be valid numbers.  Can I question why your creating such an output, it seems overly complicated to create, and would be a real pain in the neck for anyone further to use that?

ADouglas
Obsidian | Level 7

Thanks. I'll try this. This is a portion of an item analysis report that provides more item analysis information than the PROC CORR procedure, and the format of the report is better because we need to view results for a large number of test questions across the fewest number of pages possible. The statistics are generated by a SAS macro that can analyze data for an arbitrary number of multiple choice test questions. Regards, Aaron 

Astounding
PROC Star

A few steps are required;  First, before the DATA step:

 

options missing='-';

 

You can change the -8 to missing, but still need this statement to get it to print as a dash.  After the DATA step is over, you can consider whether or not you want to reset with:

 

options missing='.';

 

Next, in the DATA step (right after the SET statement), you need to transform your data.  This means first collecting all the variables that might need to be changed:

 

array eights {*} PT_Biserial_:;

 

You can add to the list if more variables belong there.

 

Then immediately change the values before the PUT statement writes them out:

 

do i=1 to dim(eights);

   if eights{i}=-8 then eights{i}=.;

end;

 

That should do it.

 

ADouglas
Obsidian | Level 7

This solution did exactly what I wanted it to do, with very few additional statements. Thanks!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1575 views
  • 0 likes
  • 3 in conversation