BookmarkSubscribeRSS Feed
TB10
Fluorite | Level 6

I have the following type of code in sql:

TRANSFORM Max(ConfigValue)
SELECT Config_ID
FROM TABLE_01
GROUP BY Config_ID
PIVOT ConfigField 

how do i convert it in sas to get the same result ?

 

@PaigeMiller @Quentin @fja @Tom 

2 REPLIES 2
yabwon
Onyx | Level 15

if it is the same case as from this stackoverflow thread: 

 

https://stackoverflow.com/questions/16691853/transform-and-pivot-in-access-2013-sql

 

then use proc Transpose (https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1xno5xgs39b70n0zydov0owajj8.htm): 

 

data TABLE_01;
  infile cards dlm="|";
  input Config_ID  (ConfigField ConfigValue) (:$20.) ;
cards;
11|         Name  |        Basic
11|      Version  |         1.01
11|        Owner  |         Jack
12|         Name  |     Advanced
12|      Version  |         1.03
12|        Owner  |         Andy
;
run;
proc print;
run;


proc transpose data=TABLE_01 out=TABLE_02(drop=_NAME_);
  by Config_ID;
  id ConfigField;
  var ConfigValue;
run;
proc print;
run;

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User

@TB10 wrote:

I have the following type of code in sql:

TRANSFORM Max(ConfigValue)
SELECT Config_ID
FROM TABLE_01
GROUP BY Config_ID
PIVOT ConfigField 

how do i convert it in sas to get the same result ?

 


What does that gibberish code do?  Show an example input.  Describe the change you want to make.  Show the resulting output for that input.

 

If you want to calculate some type of maximum value then I you might want to start with PROC SUMMARY.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 752 views
  • 2 likes
  • 3 in conversation