f



Getting Labels to Transposed variables

Hello all,

I am trying to Transpose Smpbtc variable with the Prefix of Exlot and for
all that variables I want get a label with the corresponding number. For
that I am trying to do something like this , But not there Yet any Ideas.


proc sort data=oc_data.smpsmp out= smpsmp (keep =  sbjnbr pt actevent visit
cpevent  smpbtc) ;
 by sbjnbr pt actevent visit cpevent ;
 run;

proc transpose data=smpsmp out=smp1 Prefix = exlot  ;
 by sbjnbr pt actevent  visit cpevent ;
 var smpbtc;
run;
Proc Sql Noprint ;
Create table aa as
Select  Count(Smpbtc)   as mx_count
From Smpsmp
Group By sbjnbr, pt ,actevent,  visit ,cpevent;
Select   Max (mx_count ) into :Max_count
From aa;
%put &Max_count ;
Quit ;
/* I tried this but able to make it work.
Proc Datasets library = Work Memtype = data  ;
Modify exlot ;
 Do j = 2 to &Max_count.;
Label Exlot&j = "Lot Number &J";
 End ;
Quit ;
*/
Data smp11 ;
    set smp1;
 Do j = 2 to &Max_count.;
Label Exlot(j) = "Lot Number(J)";
 End ;
Run;
0
proccontents (843)
1/27/2009 9:16:33 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
280 Views

Similar Articles

[PageSpeed] 43

Reply:

Similar Artilces:

Re: Getting Labels to Transposed variables
Hello Joe, I tried with IDLABEL and ID because the Var variable lable is different from label I want had no luck but anyway I did what I want this way do not how good solution is this ------------------------------------------------ proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent visit cpevent smpbtc) ; by sbjnbr pt actevent visit cpevent ; run; proc transpose data=smpsmp out=smp1 Prefix = exlot ; by sbjnbr pt actevent visit cpevent ; var smpbtc; run; Proc Sql Noprint ; Create table aa as Select Count(Smpbtc) as mx_count From Smpsmp Group By sbjnbr, pt ,actevent, visit ,cpevent; Select Max ( mx_count ) into :Max_count From aa; %put &Max_count ; Quit ; Data Dummy (keep = JJ EL LABELV); el = "0" ; do jj = 2 to &max_count ; Labelv = "Lot Number "!!Strip(jj); Output; End; Run; Proc Transpose data = Dummy Out = Dummy2 (Drop = _name_) Prefix = Exlot; ID jj; Idlabel labelv ; Var El; Run; Data Smp1 ; Set Smp1 Dummy2 ; Run; On Tue, Jan 27, 2009 at 4:31 PM, Joe Matise <snoopy369@gmail.com> wrote: > Look up the ID and IDLABEL options for proc transpose. > > -Joe > > > On Tue, Jan 27, 2009 at 3:16 PM, SAS_learner <proccontents@gmail.com>wrote: > >> Hello all, >> >> I am trying to Transpose Smpbtc variable with the Prefix of Exlot and for >> all that variables I want get a label with the corresponding number. For >> that I am trying to do something l...

Re: Getting Labels to Transposed variables #3
Do you mean 'variable label' or 'value label' ? I'm having trouble parsing what you are asking for. You can create in a previous datastep a variable label that is appropriate for yoru needs, and then use IDLABEL=(label variable), if you want. I think that's what you did below, if I read your code right. Seems like an awful lot of transposing, though ... -Joe On Tue, Jan 27, 2009 at 3:50 PM, SAS_learner <proccontents@gmail.com> wrote: > Hello Joe, > > I tried with IDLABEL and ID because the Var variable lable is different > from label I want > had no luck but anyway I did what I want this way do not how good solution > is this > ------------------------------------------------ > proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent visit > cpevent smpbtc) ; > by sbjnbr pt actevent visit cpevent ; > run; > proc transpose data=smpsmp out=smp1 Prefix = exlot ; > by sbjnbr pt actevent visit cpevent ; > var smpbtc; > run; > Proc Sql Noprint ; > Create table aa as > Select Count(Smpbtc) as mx_count > From Smpsmp > Group By sbjnbr, pt ,actevent, visit ,cpevent; > Select Max ( mx_count ) into :Max_count > From aa; > %put &Max_count ; > Quit ; > Data Dummy (keep = JJ EL LABELV); > el = "0" ; > do jj = 2 to &max_count ; > Labelv = "Lot Number "!!Strip(jj); > Output; > End; > Run; > Proc Transpos...

Re: Getting Labels to Transposed variables #6
Hello Joe , Let me try will let you know. Thank you for Code snipnet, thanks SL On Tue, Jan 27, 2009 at 7:38 PM, Joe Matise <snoopy369@gmail.com> wrote: > That's not a problem. > > I can't say what your dataset looks like before hand as you didn't provide > an example, but I could guess; > > proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent visit > cpevent smpbtc) ; > by sbjnbr pt actevent visit cpevent ; > run; > > data spmsmp_2; > set smpsmp; > by sbjnbr pt actevent visit cpevent; > retain counter; > if first.cpevent then counter=0; > counter+1; > *create an ID and IDlabel here; > idval = cats('exlot',counter); > idlbl = (label); *put whatever code you want to set your labels up here; > run; > > I don't know what you want to use as a label, that isn't clear, but you can > use that code to create it, I think. It should make a unique ID for each > record in any given by-group, and then you can similarly label it however > you prefer to label it. Then when you PROC TRANSPOSE use id=idval and > idlabel=idlbl. You just have to have a unique ID for each record in any > given BY-group, or they will overwrite. > > This would be a bit easier if you provided some sample data ... here's an > example using my own sample data. > > data > test; > > input > > smpbtc sortkey1 > sortkey2; > > cards; > &...

Re: Getting Labels to Transposed variables #2
Look up the ID and IDLABEL options for proc transpose. -Joe On Tue, Jan 27, 2009 at 3:16 PM, SAS_learner <proccontents@gmail.com> wrote: > Hello all, > > I am trying to Transpose Smpbtc variable with the Prefix of Exlot and for > all that variables I want get a label with the corresponding number. For > that I am trying to do something like this , But not there Yet any Ideas. > > > proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent visit > cpevent smpbtc) ; > by sbjnbr pt actevent visit cpevent ; > run; > > proc transpose data=smpsmp out=smp1 Prefix = exlot ; > by sbjnbr pt actevent visit cpevent ; > var smpbtc; > run; > Proc Sql Noprint ; > Create table aa as > Select Count(Smpbtc) as mx_count > From Smpsmp > Group By sbjnbr, pt ,actevent, visit ,cpevent; > Select Max (mx_count ) into :Max_count > From aa; > %put &Max_count ; > Quit ; > /* I tried this but able to make it work. > Proc Datasets library = Work Memtype = data ; > Modify exlot ; > Do j = 2 to &Max_count.; > Label Exlot&j = "Lot Number &J"; > End ; > Quit ; > */ > Data smp11 ; > set smp1; > Do j = 2 to &Max_count.; > Label Exlot(j) = "Lot Number(J)"; > End ; > Run; > ...

Re: Getting Labels to Transposed variables #5
Hello Joe, Well when I did Transpose proc transpose data=smpsmp out=smp1 Prefix = exlot ; by sbjnbr pt actevent visit cpevent ; var smpbtc; run; There were Seven Variable Exlot1 -- Exlot7 and for these variables I want the Lables, I can't Know before hand how many would be there . Thanks SL On Tue, Jan 27, 2009 at 5:15 PM, Joe Matise <snoopy369@gmail.com> wrote: > Do you mean 'variable label' or 'value label' ? I'm having trouble parsing > what you are asking for. > > You can create in a previous datastep a variable label that is appropriate > for yoru needs, and then use IDLABEL=(label variable), if you want. I think > that's what you did below, if I read your code right. > > Seems like an awful lot of transposing, though ... > > -Joe > > > On Tue, Jan 27, 2009 at 3:50 PM, SAS_learner <proccontents@gmail.com>wrote: > >> Hello Joe, >> >> I tried with IDLABEL and ID because the Var variable lable is different >> from label I want >> had no luck but anyway I did what I want this way do not how good solution >> is this >> ------------------------------------------------ >> proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent >> visit cpevent smpbtc) ; >> by sbjnbr pt actevent visit cpevent ; >> run; >> proc transpose data=smpsmp out=smp1 Prefix = exlot ; >> by sbjnbr pt actevent ...

Re: Getting Labels to Transposed variables #4
That's not a problem. I can't say what your dataset looks like before hand as you didn't provide an example, but I could guess; proc sort data=oc_data.smpsmp out= smpsmp (keep = sbjnbr pt actevent visit cpevent smpbtc) ; by sbjnbr pt actevent visit cpevent ; run; data spmsmp_2; set smpsmp; by sbjnbr pt actevent visit cpevent; retain counter; if first.cpevent then counter=0; counter+1; *create an ID and IDlabel here; idval = cats('exlot',counter); idlbl = (label); *put whatever code you want to set your labels up here; run; I don't know what you want to use as a label, that isn't clear, but you can use that code to create it, I think. It should make a unique ID for each record in any given by-group, and then you can similarly label it however you prefer to label it. Then when you PROC TRANSPOSE use id=idval and idlabel=idlbl. You just have to have a unique ID for each record in any given BY-group, or they will overwrite. This would be a bit easier if you provided some sample data ... here's an example using my own sample data. data test; input smpbtc sortkey1 sortkey2; cards; 1 101 101 2 101 101 5 101 101 1 101 102 2 101 102 3 101 102 5 101 102 8 101 102 1 101 103 2 101 103 4 101 103 ;;;; run; proc sort data=test; by sortkey1 sortkey2; run; data smpsmp; set test; by sortkey1 sortkey2; if first.sortkey2 then counter=0; counter+1; idval = cats('exlot',counter); idlbl = cats('External Lot #...

Make new variable label consisting of variable name & variable label
LS, I would like to do the following for a file with thousands of variables: Name : variabl1 Label: Household income 1990 New label: variable1_Houshold income 1990 If a variable name is shorter then 8 positions, it should be filled with underscores. Thus: Name : var1 Label: Household income 1990 New label: var1_____Houshold income 1990 I hope this is clear and thanks in advance for your input, Gerben On 10 Oct 2003 02:40:48 -0700, gerbenvnu@hotmail.com (gerben) wrote: >LS, > >I would like to do the following for a file with thousands of >variables: > >Name : variabl1 >Label: Household income 1990 > >New label: variable1_Houshold income 1990 > >If a variable name is shorter then 8 positions, it should be filled >with underscores. Thus: > >Name : var1 >Label: Household income 1990 > >New label: var1_____Houshold income 1990 > >I hope this is clear and thanks in advance for your input, > >Gerben Hi load your data file then run the folowing script: ' Raynald Levesque 2003/10/10 Option Explicit Sub Main() ' Declare variables and get the variable list: Dim objSpssInfo As ISpssInfo Dim var As String Set objSpssInfo = objSpssApp.SpssInfo Dim lngNumber As Long Dim i As Long Dim strCmd As String lngNumber = objSpssInfo.NumVariables strCmd = "VARIABLE LABELS " Debug.Clear With objSpssInfo For i = 0 To lngNumb...

Any trick to get SAS variable name?
Hi All, I am working on a data set and would like to break each variable(SNP) into two variables with similar name. for example: original data: varx vary varz... ~1000 variables AG CT AC new data: varx_1, varx_2, vary_1, vary_2.... A G C T I am thinking about using Arrays (array snp{*} _all_} and macro variables. Is there anyway to know the variable name of ith element in array "SNP"? thanks, Vincent ...

Assign variables to a new variable based on variable names in SAS
Thank so much Nagakumar Sridhar and Fehd, Ronald J. for answering my previous question. However I was not clear in the original post. I modified my phrasing and the new version is below: I have met the following problem and I need your expert help. The variable names in the data set looks like this: a_1995q3 a_1995q4 a_1997q1 ........... a_2003q4 n Please note that "quarter" numbers in "a_****q*" variables may not be continuous, i.e. there might be a missing quarter. and n can have the value of any quarter for while a_quarter exists, say "1995q3", "...

Re: Any trick to get SAS variable name?
Vincent, Depending upon which you are trying to get, you probably want either vname or vvalue. E.g., data original; input (varx vary varz) ($); cards; AG CT AC ; data new; set original; array vars(*) _all_ varx--varz; do i=1 to 3; x=vname(vars(i));; put x; y=vvalue(vars(i)); put y; end; run; HTH, Art --------- On Tue, 27 Oct 2009 15:57:08 -0700, duo wan <duo_wan@YAHOO.COM> wrote: >Hi All, > >I am working on a data set and would like to break each variable(SNP) into two variables with similar name. for example: > >original data: > &...

Getting variable label value in DATA STEP?
Let's just say I have a variable x in dataset work.y and I want to dump its label into a text variable xl. Is is possible? I suppose I could do PROC CONTENTS, dump the output, then merge it back but surely there's an easier way. The problem is that someone had PROC TRANSPOSED On May 15, 6:29=A0pm, "Kenneth M. Lin" <kenneth_m_...@sbcglobal.net> wrote: > Let's just say I have a variable x in dataset work.y and I want to dump i= ts > label into a text variable xl. =A0Is is possible? =A0I suppose I could do= PROC > CONTENTS, dump the outp...

Re: SAS/AF: Get List of all SCL Variables
Paul, Would this help?: http://www.devenezia.com/downloads/sas/af/index.php?topic=16 Art ------ On Mon, 28 Jul 2008 18:05:22 -0400, Paul Walker <walker.627@OSU.EDU> wrote: >I want to get a list of all SCL variables used or created by my frame so >that I can explicitly declare all of them at the top of the program. Is >there a way I can get a comprehensive list of the SCl variables? ...

Re: SUSPECT: Any trick to get SAS variable name?
Hi duo_wan, I have created the macro %two_var the most efficient I could: data test; input varx $ vary $ varz $; cards; AG CT AC ;; run; *************************; %let libname= work; %let table= test; *************************; %macro two_var; %let dsn=%sysfunc(open(&libname..&table,i)); %do i=1 %to %sysfunc(attrn(&dsn,nvars)); %if %sysfunc(vartype(&dsn,&i))=C %then %do; %do n=1 %to 2; %let vname=%sysfunc(varname(&dsn,&i)); %let dsnvar&n =%sysfunc(cats(%sysfunc(varname(&dsn,&i)),_,&n)); &&dsnvar&n.=substr(&vname,&n,1); %e...

Re: Getting TTEST (and other PROCS) to print variable labels
i think it is a good practice to use more generic variable names such as VAR1. if you want a more clear label, you can manage to do so in some tables for meta data. from practice of database, it is bad to use descriptive variable names in a data table. On Feb 4, 2008 2:02 PM, Peter Flom <peterflomconsulting@mindspring.com> wrote: > Hi > > I looked at the documentation for TTEST and googled a bit, but didn't see a way to get PROC TTEST to print variable labels instead of variable names. People at my current place of employment are fond of giving variables names like VAR1, a...

Getting TTEST (and other PROCS) to print variable labels instead
Hi I looked at the documentation for TTEST and googled a bit, but didn't see a way to get PROC TTEST to print variable labels instead of variable names. People at my current place of employment are fond of giving variables names like VAR1, and then using labels. They've been collecting data for 30 years, so they aren't going to change (and there's no way to change all the data sets they have). So, is there a way to get PROC TTEST to do this? Is there general guidance on how to make SAS PROCs print labels instead of variable names? TIA as always Peter ...

FW: SAS/AF: Get List of all SCL Variables
A little more info about the Static Analyzer: You can click on a row/variable on the Variables tab to see more info about the variable including length, storage, and line number. Click on the details display to see the actual code. The variables data is in the Static Analyzer data set named sclstat7. -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Randy Herbison Sent: Tuesday, July 29, 2008 9:51 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: SAS/AF: Get List of all SCL Variables Paul, The Static Analyzer will display a list of frame entry varia...

Re: SAS/AF: Get List of all SCL Variables #2
>Would this help?: >http://www.devenezia.com/downloads/sas/af/index.php?topic=16 This looks like a nifty tool for visualizing SCL lists. Which list would you suggest that I plug into it for getting an overview of all the SCL variables used in my frame? - Paul ...

Re: Assign variables to a new variable based on variable names in SAS #6
Hi, Richard, Your data step, "monkeyshines" is one of the prettest I have ever seen. Really nice. The to-the-point array statement using the variable name wild character (":"); use of lbound() hbound() functions; use of _i_ for index variable; short but intuitive variable and array names like aVars, aBase, and aMap; use of intnx and intck functions, reading the returned variable name with ??yyq6. format, anticipation of range checking, and all the work was done in essentially a single line!("a_new = aVars[aMap[qtrIndex]];") ... I learn a lot just by reading your...

Re: Assign variables to a new variable based on variable names in SAS #5
Hi Chang & V - I'm confused as usual - did you mean this? 142 data one; 143 a_1995q3 = 1; 144 a_1995q4 = 2; 145 a_1997q1 = 3; 146 a_2003q4 = 5; 147 n = "2003q4"; 148 run; NOTE: The data set WORK.ONE has 1 observations and 5 variables. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds 149 150 data two; 151 set one; 152 call symput('n', n); 153 new_a = 'a_'||resolve(n); 154 put new_a=; 155 run; new_a=a_2003q4 NOTE: There were 1 observations read from the data set WORK.ONE...

Re: Assign variables to a new variable based on variable names in SAS #3
Here's a solution that builds a list of subscripts in macro variables named like the 'a_' columns in the input dataset. 'a_' fields are referenced by the subscript from the array they're defined to be part of: data stuff; a_2003q4 = 44; a_2003q1 = 11; a_2003q2 = 22; a_2003q3 = 33; n = 'a_2003q3'; run; proc sql noprint; create table columns as select name from sashelp.vcolumn where libname = 'WORK' and memname = 'STUFF' and name eqt 'a_' order by name ; select compbl('...

Re: Assign variables to a new variable based on variable names in SAS #7
Chang, I agree with your assessment of Richard's code. I especially liked that he offered it without any chest pounding! Joe -----Original Message----- From: "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM> Sent: Jan 16, 2004 11:19 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Assign variables to a new variable based on variable names in SAS Hi, Richard, Your data step, "monkeyshines" is one of the prettest I have ever seen. Really nice. The to-the-point array statement using the variable name wild character (":"); use of lbound() hbound() f...

Re: SAS/AF: Get List of all SCL Variables #3
Paul, The Static Analyzer will display a list of frame entry variables (including type and frequency). To use the Static Analyzer, first collect data about the application: proc build batch; crossref project=work.new.test.frame outlib=work; run; Then run the command: SCLPROF STATIC lib=work Select the View Data button on the Static Analyzer window and then the Variables tab. -Randy -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Paul Walker Sent: Monday, July 28, 2008 11:39 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: SAS/AF: Get List o...

Re: Assign variables to a new variable based on variable names in SAS #4
On Thu, 15 Jan 2004 11:02:05 -0800, W M <mwx74@HOTMAIL.COM> wrote: >I have met the following problem and I need your expert help. >The variable names in the data set looks like this: > >a_1995q3 a_1995q4 a_1997q1 ........... a_2003q4 n > Is there a way like > >new_a=a_{value of n} ? > >Because of the compilation of data step, you cannot do > >data new; set old; >call symput("name", n); >new_a=a_&n; (wrong !) >run; Hi, V, Following up on Paul (Choate)'s idea, this seems to work. This would serve as an example of putting an...

Can I send SAS variable labels to SQL Server field descriptions?
Hello, =20 I am currently moving data from SAS 9.1 on Windows to SQL Server 2005. =20 I am using a LIBNAME statement with ODBC and the BULKLOAD=3DYES = parameter. (I started using the BULKLOAD parameter on the LIBNAME statement to get away from DBLOAD, and I don't want to go back. Transfer times have reduced considerably.) =20 Example: =20 libname pacdb odbc noprompt=3D"dsn=3Dpacenrl;" bulkload=3Dyes; =20 * create SQL Server table from SAS dataset ; data pacdb.need; set have; run; =20 =20 When I run my job, I see a note in the log that says: =20 =20 NOTE: S...

Web resources about - Getting Labels to Transposed variables - comp.soft-sys.sas

More Fantastic Posters of Movies Transposed to Earlier Eras by Designer Peter Stults
Back in 2012 we posted about a clever poster series in which designer Peter Stults transposed famous movies to earlier eras with different casts ...

New Zealand’s Contribution to the Venice Biennale: A Library and an Airport, Transposed
The artist Simon Denny has repurposed imagery from the Biblioteca Nazionale Marciana in Marco Polo International's arrivals hall, and vice versa. ...

Landscapes and City Skylines Transposed Into Musical Notation
The Sapporo skyline “Note Drawing” is an intriguing series by Japanese artist Koshi Kawachi that transposes city skylines and the contours of ...

Resources last updated: 3/16/2016 12:52:33 PM