BookmarkSubscribeRSS Feed
CH33
Calcite | Level 5

Hello SAS friends and happy New Year!  I am glad you are here to help because I sure need it. I am using SAS 9.4 on a PC. I have a large data set that was created through a simulation and needs to be analyzed. There are 28,800 test sets broken up into segments of  2000. I did this because I thought it might be easier to analyze - probably wasn't. A set of 400 test set represents a certain set of simulation conditions. Each test set contains 20 items (columns) and 250 cases (rows).  Each test set is different: if any of the items are replicated across test sets, it happened randomly. 

 

The code I am using is supposed to analyze each item in a test set (1-20), get a p-value for each item (20 p-values), and move onto the next test set. So I should get 20 different p-values for test set 1, 20 different for test set 2 etc etc all the way to 28,800 test sets.

 

But that is not what is happening or at least that isn't what happens most of the time.  I usually get the same p-values for all item 1s in every test set, and all item 2s in every test set. or all the p-values are the same. I have emailed SAS technical help but it is working OK for them, which is frustrating because it does work OK sometimes...and then it doesn't. I worked with someone over the break and he got it to work well for 10 test sets so we tried a run of 2000 and check them this morning - they were all the same.

 

I have attached some of my practice results so you can see how erratic they are. I also attached the code for the macro that should loop through the data sets. Last, I included 2 test sets. I didn't attach the entire code because some parts are proprietary.

 

I sure hope someone can help.

 

carol

6 REPLIES 6
ballardw
Super User

You really should share the code you are using as well as providing the code to create data set from the CSV file. If you intended to attach macro code it apparently didn't make it.

 

Generic sense, instead of creating multiple data sets to create "groups" of analysis it may make more sense to include a variable that indicates the "analysis group" you want and then use that variable as a BY variable to get multiple analysis without macro loops.

 

I may make choices for reading a given file that would NOT duplicate your results.

 

CH33
Calcite | Level 5

Hello, I thought I did include the macro that ran the results - it could be that this app only accepts one or two attachments.  Here is my macro.  Thank you for your suggestion.

 

carol

Tom
Super User Tom
Super User

It looks like you are trying to read in 5 different files and generate 5 different output files.

Are you sure that where the output are matching it is not because the inputs are matching?  If not then check the log for errors that might cause it to not replace the generated outputs from the submacro %PVALS().  You might want to add a step to remove the temporary datasets to prevent SAS from just re-using the old version.

proc delete data=all1-all20;
run;

Note there is no need to wrap SAS code into a WORD file and then attach it as a file. You can just post it using the Insert SAS Code button on the forum editor.

%macro maketable(number);
%do i=1 %to &number;
PROC IMPORT OUT= WORK.b1 
/*CHANGE THE LINE BELOW TO THE FILE LOCATION OF TEST SETS*/
  DATAFILE= "C:\Users\mdto223\Dropbox\Carol_Simulation\Checking Work\Checking SAS Syntax\Data1\TestSet&i..csv" 
  DBMS=csv REPLACE;
RUN;
%pvals(b1,item1,all1)
%pvals(b1,item2,all2)
%pvals(b1,item3,all3)
%pvals(b1,item4,all4)
%pvals(b1,item5,all5)
%pvals(b1,item6,all6)
%pvals(b1,item7,all7)
%pvals(b1,item8,all8)
%pvals(b1,item9,all9)
%pvals(b1,item10,all10)
%pvals(b1,item11,all11)
%pvals(b1,item12,all12)
%pvals(b1,item13,all13)
%pvals(b1,item14,all14)
%pvals(b1,item15,all15)
%pvals(b1,item16,all16)
%pvals(b1,item17,all17)
%pvals(b1,item18,all18)
%pvals(b1,item19,all19)
%pvals(b1,item20,all20)
/*combining pvalue tables together*/
data allitems;
  set all1 all2 all3 all4 all5 all6 all7 all8 all9 all10
      all11 all12 all13 all14 all15 all16 all17 all18 all19 all20
  ;
run;

proc print;
run; 

/*CHANGE THE BELOW LINE TO THE FILE LOCATION OF THE OUTPUT TABLES*/
proc export data=allitems dbms=csv
  outfile="C:\Users\mdto223\Dropbox\Carol_Simulation\Checking Work\Checking SAS Syntax\OutputTable&i..csv"
  replace
;
run;
/*dm 'log;clear;output;clear;'*/
%end;
%mend;

/*Running macro*/
%maketable(5)
CH33
Calcite | Level 5

Hi Tom, and thank you - that makes sense to me.  Where would I put that line of code?

Tom
Super User Tom
Super User

Put it right after the %DO statement.  You might want to also delete dataset generated by the IMPORT  and the combined dataset.

SASKiwi
PROC Star

So what does your SAS log report when you get the same answers over and over again? Do you have any errors or warnings? If so fix them. Once you get a clean log, does your problem still happen? If so what is different about the log of a non-repeated result versus a repeated one? This should be your starting point to understand what is going on.

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!

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
  • 6 replies
  • 613 views
  • 0 likes
  • 4 in conversation