+ Reply to Thread
Results 1 to 4 of 4

Thread: sas coding question

  1. #1
    Points: 11, Level: 1
    Level completed: 21%, Points required for next Level: 39

    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sas coding question



    Hi
    I need the coding for the following;
    /*task*/
    data r;
    input info $ 1 - 50;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;

    I need to find the coding for the above.
    want the colums to be named prid priname and prqty.

    prid and prqty ( should be numerical when u check the data file)
    priname should be (character)
    I can get the code if i manipulate the data.

    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;

    can u help get the code

  2. #2
    RotParaTon
    Points: 46,287, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Discussion EnderPosting AwardFrequent PosterCommunity AwardMaster Tagger
    Dason's Avatar
    Location
    Ames, IA
    Posts
    9,083
    Thanks
    211
    Thanked 1,609 Times in 1,379 Posts

    Re: sas coding question

    Hi! We are glad that you posted here! This looks like a homework question though. Our homework help policy can be found here. We mainly just want to see what you have tried so far and that you have put some effort into the problem. I would also suggest checking out this thread for some guidelines on smart posting behavior that can help you get answers that are better much more quickly.
    "His programming is malfunctioning. It begins! Get your weapons, he's going to become a killbot!!!" - bryangoodrich

  3. #3
    Points: 11, Level: 1
    Level completed: 21%, Points required for next Level: 39

    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: sas coding question

    Quote Originally Posted by Dason View Post
    Hi! We are glad that you posted here! This looks like a homework question though. Our homework help policy can be found here. We mainly just want to see what you have tried so far and that you have put some effort into the problem. I would also suggest checking out this thread for some guidelines on smart posting behavior that can help you get answers that are better much more quickly.
    hi i actually worked on this for couple of days

    answer is;

    my answer is
    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;


    but i did manipulate the data. I don't know any other way to arrive at the answer.
    my answer is
    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;


    but i did manipulate the data. I don't know any other way to arrive at the answer.
    my answer is
    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;


    but i did manipulate the data. I don't know any other way to arrive at the answer.
    my answer is
    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;


    but i did manipulate the data. I don't know any other way to arrive at the answer.

    my answer is
    data o;
    input prid info $4-30 pqrty;
    cards;
    101 pencils 42
    102 parker pens 21
    103 apple ipod touch n shuffle 09
    104 dell studio laptop 02
    run;


    but i did manipulate the data. I don't know any other way to arrive at the answer.

  4. #4
    TS Contributor
    Points: 6,808, Level: 54
    Level completed: 29%, Points required for next Level: 142

    Posts
    775
    Thanks
    0
    Thanked 70 Times in 69 Posts

    Re: sas coding question


    Code: 
    data o;
      set r;
    
      prid=input(substr(info,1,3),8.); *1st 3 chars of INFO, input() forces it to num type;
      priname=substr(info,5,length(substr(info,5))-3); *use length() as input to substr() since priname can vary in length;
      prqty=input(substr(info,length(info)-2),8.);
    run;

+ 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