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

Thank you so much Arthur!!! it runs exactly the way I want.you've helped me tremendously!!!

Sherri
Calcite | Level 5

Hi Arthur, I was trying to do the same thing for "type" and "day" like you did for "dept", which is filling the empty cell with the value of the record about it untill the new value and so on. But without success. can you show me what the correct code should be? Thanks very much again for your help! 

art297
Opal | Level 21

I don't have time to test any of this, this week, but here is a changed version of the code that does the same thing for type and day.  I've put /* <- */ comments to the right of each line that I either changed or added:

filename mydata "c:\art\test\*.txt";

data want (drop=dept_in type_in day_in);                           /* <- */

  infile mydata lrecl=131 pad truncover eov=newfile;

  informat patient dept dept_in product $char10.;

  informat charge_description $24.;

  informat ordering_md type $12.;

  informat type type_in $2.;                                              /* <- */

  informat day day_in anydtdte8.;                                     /* <- */

  format day date9.;

  informat class $char16.;

  informat ip_volume charge_quantity 4.;

  format ip_volume charge_quantity 4.1;

  informat actual_cost total_charge comma9.;

  format actual_cost total_charge comma9.2;

  retain patient dept type day;                                         /* <- */

  input @;

  if newfile then do;

    counter=1;

    newfile=0;

  end;

  else counter+1;

  if counter eq 3 then do;

    input @ "ENCOUNTER " patient;

  end;

  else if input(substr(_infile_,123),?? comma9.) and

    substr(_infile_,10,15) ne "CHARGE QUANTITY" then do;

    input

     dept_in 2-11

     @13 product &

     @24 charge_description &

     @49 ordering_md &

     type_in 64-65                                                                        /* <- */

     day_in 67-75                                                                         /* <- */

     class 76-92

     @94 ip_volume

     @103 charge_quantity

     @112 actual_cost

     @123 total_charge

    ;

    if not missing(strip(dept_in)) then dept=dept_in;

    if not missing(strip(type_in)) then  type=type_in;                      /* <- */

    if not missing(day_in) then  day=day_in;                                 /* <- */

    output;

  end;

  else input;

run

;

Sherri
Calcite | Level 5

I see I overlooked the retain command. you are just great!! I really appreciate your help Arthur!

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
  • 18 replies
  • 1224 views
  • 3 likes
  • 5 in conversation