+ Reply to Thread
Results 1 to 8 of 8

Thread: Cant resolve a script

  1. #1
    Points: 731, Level: 14
    Level completed: 31%, Points required for next Level: 69

    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cant resolve a script




    Hello, I would like to ask you for help. I am not a SAS user but now I try to solve one script from a book. Please find attached print screen. Could you please explain what should occur after a run the script? Unfortunately I don't know SAS syntax and the answer is urgent for me.

    What exactly means the part "set data.deve (in = a) data.deve (in = b);". What the author tried to do before the logistic regression?? What are "a" and "b"? They are in the previous imported data or they are now generated?

    Thank you very much!
    Attached Images  

  2. #2
    Points: 4,515, Level: 42
    Level completed: 83%, Points required for next Level: 35
    Con-Tester's Avatar
    Posts
    165
    Thanks
    3
    Thanked 59 Times in 57 Posts

    Re: Cant resolve a script

    The “a” and “b” are indicators that are used to decide whether the record currently being processed in the “data” step comes from the first dataset or the second one. They are numerical values and will have the value 0 or 1—0 if the current record is not in the dataset to which the indicator belongs, or 1 if it is. So, a record from the first dataset has a = 1 and b = 0, while a record from the second one has a = 0 and b = 1.

    Normally, the two (or more) datasets would be different ones, though with the same columns (but again, not always). That is, the usual syntax would be something like “set s1 (in = a) s2 (in = b) s3 (in = c) …;” and therefore I suspect that “set data.deve (in = a) data.deve (in = b);” may be a typo.

    If it is not a typo, then the output dataset (“data deve;” in the “work” library—the screenshot is too fuzzy to read clearly) will contain double the number of records in “data.deve” except that the duplicate records will have different values for the “y2” and “wt” variables.

    The subsequent “proc logistic” step then fits a logistic model to the data.

  3. #3
    Points: 731, Level: 14
    Level completed: 31%, Points required for next Level: 69

    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cant resolve a script

    Thank you very much. But still I have problem to understand the whole process...Please, check my hypothesis below.

    First of all, "If it is not a typo, then the output dataset (“data deve;” in the “work” library—the screenshot is too fuzzy to read clearly) will contain double the number of records in “data.deve” except that the duplicate records will have different values for the “y2” and “wt” variables."

    yes, you are right, the result should be to duplicate observations but with different y2 and its respective weight

    But, how does the procedure "set data" work?

    for simplified purpose lets imagine that this is my raw data (result of import procedure):

    y var1 var2
    0.2 25 1
    0 20 0.88
    0.99 50 1.55

    How will my data look like after “set s1 (in = a) s2 (in = b) s3 (in = c) …;” ?

    y var1 var2 s1 y2 wt
    0.2 25 1 a 1 0.2
    0 20 0.88 a 1 0
    0.99 50 1.55 a 1 0.99
    0.2 25 1 a 0 0.8
    0 20 0.88 a 0 1
    0.99 50 1.55 a 0 0.01

    This will be my results?

    If yes, how can the procedure differentiate to which rows assign the "a" and to which rows assign the "b"?

    please, try to explain me the procedure of "set data" because it is very important for me how it works...Lets imagine that I need to adjust my data in Excel in the same way how it did the SAS in the procedure in the print screen. Thank you in advance!

  4. #4
    Points: 4,515, Level: 42
    Level completed: 83%, Points required for next Level: 35
    Con-Tester's Avatar
    Posts
    165
    Thanks
    3
    Thanked 59 Times in 57 Posts

    Re: Cant resolve a script

    I used “set s1 (in = a) s2 (in = b) s3 (in = c) …;” as a general example to show the syntax of the “in” indicator variables, i.e. “a”, “b”, “c”, etc. The “s1”, “s2”, “s3”, etc. are dataset names, not variable names. The “data” step runs through each dataset listed in the “set” clause in the order in which they are listed.

    Using your example for the dataset “data.deve” (see attached Fig1.png), after running the “data” step (the code from “data deve;” to the first “run;” statement) will output a dataset called “deve” that lives in the SAS session’s “work” library and has the contents as shown in the attached Fig2.png.

    If you still don’t understand, run the code in SAS yourself.
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	Fig1.png‎
Views:	6
Size:	2.3 KB
ID:	6512   Click image for larger version

Name:	Fig2.png‎
Views:	6
Size:	3.9 KB
ID:	6513  

  5. #5
    Points: 731, Level: 14
    Level completed: 31%, Points required for next Level: 69

    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cant resolve a script

    Thank you very much. Your demonstration using tables helped me

    BTW: i tried to run the script (after replacing name of database and attributes), but it doesn't work. It gave me a error message that my table may be not complete or something... Have you tried to run it?? (maybe it is truly a type as you mentioned but it is from a research paper)

  6. #6
    Points: 4,515, Level: 42
    Level completed: 83%, Points required for next Level: 35
    Con-Tester's Avatar
    Posts
    165
    Thanks
    3
    Thanked 59 Times in 57 Posts

    Re: Cant resolve a script

    I did run it for the example data you provided, after generating a “deve” dataset with three records, as per the example.

    You need to copy the contents of the SAS log and post it here (or provide a nice and legible screen shot thereof) because your description is insufficient. Maybe a library is not assigned or a dataset is missing or there’s a syntax error.

  7. #7
    Points: 731, Level: 14
    Level completed: 31%, Points required for next Level: 69

    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Cant resolve a script

    I will try it again and let you know...

  8. #8
    Fortran must die
    Points: 52,364, Level: 100
    Level completed: 0%, Points required for next Level: 0
    noetsi's Avatar
    Posts
    6,479
    Thanks
    681
    Thanked 912 Times in 871 Posts

    Re: Cant resolve a script


    Printing the log would help a lot.
    "Very few theories have been abandoned because they were found to be invalid on the basis of empirical evidence...." Spanos, 1995

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats