BookmarkSubscribeRSS Feed
Best
Calcite | Level 5
Hi,

I have two questions to ask.
1 is there any alternative if firstdot and last dot? Not using group by in proc sql

2 How can we transpose a data set without using Proc transpose?


2 REPLIES 2
Kurt_Bremser
Super User

1) no. If you need them, you need them. For clarity, post the code you want an alternative for.

2) with lots of data step and macro coding, as you need to have dynamic code (variable names) depending on the data.

ballardw
Super User

@Best wrote:
Hi,

I have two questions to ask.
1 is there any alternative if firstdot and last dot? Not using group by in proc sql

2 How can we transpose a data set without using Proc transpose?



1) A concrete example of what you are attempting would help. Some techniques might work for some cases but not others because this is very likely to be very dependent on data and result needed.

 

2) A data step relatively easy will transpose from wide to long

data have;
input a $5.  var1 var2 var3;
cards;
19701 8798  123 456
19701 5489  789 333
18054 3578  908 222
;
Run;

data trans;
   set have;
   array v var1-var3;
   do i= 1 to dim(v);
      tranval= v[i];
      output;
   end;
   keep a tranval;
run;

from long to wide takes a few more steps to determine max number of resulting variables, create the appropriate variable names, Retain statement and conditional output.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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