BookmarkSubscribeRSS Feed
VictorNilsson
Calcite | Level 5

Hi, I am a new user in SAS and i have encountered a problem that I need help to solve. 

 

I have an issue when using the split column function in SAS EG. 

 

I have a Data-set with the following example columns: 

 

User_ID  Segment  Product  Period      Revenue

12345     Retail        Shoes    2016-02   500

 

I would like to use the split function in order to get the period spltted into several new columns for each month of the year, instead rows. Somehow, when I perform the split column task, it adds about 20% to the total revenue. Before making the split I have used the sum function for the revenue. 

 

Can someone please tell me what I am doing wrong here? 🙂 

 

 

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Is period a date variable?  If so you wouldn't split it (which is for character strings) but rather extract the various parts using year() or month() functions.  E.g.:

data want;
  set have;
  yr=year(period);
  mnth=month(period);
run;
VictorNilsson
Calcite | Level 5

@RW9 Period is formated as charachter string and revenue in number format. 😕

 

First I assumed that it would be better to use the "Transpose function"? But as i understood it, the transpose function is preferably used in the opposite way, whenever you would like to transpose a column into a row? It feels like i'm swimming in the deep water over here 🙂 haha.  

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

All I can think is that with the extra variables its grouping the data differently.  Sorry, I don't use EG so can't be further help as I only use code.  Transpose can be used either way, normalised to transposed and vice versa.  If you have multiple variables or different types then arrays can be more effective.

ballardw
Super User

Maybe you should be looking at REPORTING tasks where the variable Period has a grouping column role.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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