DATA Step, Macro, Functions and more

Update/Move Column Contents

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

Update/Move Column Contents

I have attached testdata.xls file.

 

Here is the issue, look at Obs # 1.

How can I make obs # 1 that should mimic to obs # 2 ?

 

Somehow file got corrupted, and contents splitted and shifted one column to the right in obs # 1 Column A (obs # 1),

Obs # 2 is correct way of representation of data.

 

In Obs # 1,

Salesman_name_dept should be : Michael Perry A001 Manufacturing

Sale_date should be :  10-Jan-09

Reorder should be : 50

Event should be : 10

BuySell should be : 45.45

Amount should be : 5000.75

 

Appreciate any help !

 


Accepted Solutions
Solution
‎08-16-2016 01:58 PM
Contributor
Posts: 69

Re: Update/Move Column Contents

Issue has been resolved. Thanks to SAS communities members !

 

- GPatel

View solution in original post


All Replies
Super User
Posts: 11,336

Re: Update/Move Column Contents

Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Use this link to create a data step that you can post as text or attach as a text file for better description of your data: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

It also helps to provide the layout of the expected results.

Trusted Advisor
Posts: 1,553

Re: Update/Move Column Contents

You can repair your data-set  by overriding 1st observation values.

Pay attention to variables type:  CHAR or NUM to write the correct values as correct litterals;

 

 

data new;

 set old;

   if _N_ = 1 then do;

    Salesman_name_dept = "Michael Perry A001 Manufacturing";

    Sale_date =  '10Jan09'd;

    Reorder    = 50;

    Event = 10;

    BuySell = 45.45;

    Amount = 5000.75;

 end;

run;

 

 

Solution
‎08-16-2016 01:58 PM
Contributor
Posts: 69

Re: Update/Move Column Contents

Issue has been resolved. Thanks to SAS communities members !

 

- GPatel

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 391 views
  • 0 likes
  • 3 in conversation