f



Re: Converting Macro Variable to a SAS Dataset Variable

Refer to my previous answer; if you put them in a data set then =
transpose
the data set, you avoid macro variables altogether.  However, to answer =
the=20
question:

data newtable;
informat p1 8.;
p1=3D&p1;
run;

To assign character variables, use the macro variable in double quotes
informat char_var $20.;
char_var=3D"&macro_var";

-Mary

  ----- Original Message -----=20
  From: Siddharth Jain=20
  To: SAS-L@LISTSERV.UGA.EDU=20
  Sent: Wednesday, March 18, 2009 10:22 AM
  Subject: Converting Macro Variable to a SAS Dataset Variable


  If I have a macro variable p1 where %put <<p1>>; results in <<p1>> =
01,02,03,06


  How do I bring value of p1 to a dataset. Can I make a dataset variable =
which
  has the same values as of p1.


  Thanks in advance for your help,
  Siddharth
0
mlhoward (1803)
3/18/2009 3:53:37 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
857 Views

Similar Articles

[PageSpeed] 27

Reply:

Similar Artilces:

Re: Converting Macro Variable to a SAS Dataset Variable #4
Siddharth, If I understand properly, you are looking to identify, for each subject / organ code (where here is organ code, by the way - is that lasticd?), whether there is a difference between one visit and the next? For that I imagine you're best off using one of the various stat procs, I'm not an expert in that area but there are plenty of ways of analyzing change over (variable) of (variable). You could also normalize your data (if it's not already, that's not clear) by visit date and create three visit date tables, one for each date of interest, and then merge them together, then creating a fourth variable as the difference between the three. -Joe On Wed, Mar 18, 2009 at 10:41 AM, Siddharth Jain <sjain@aveopharma.com>wrot= e: > Hello Joe, > > > > Thanks for your response. Below is the code I have up till now: > > > > Per subjid per visit per organ code, I have to see whether result is > changing or not. > > > > Thanks, > > Siddharth > > > > > > > > *data* la11; > > set la; > > if lacat in ('NTL=92) and subjid in ('101-001'); > > keep subjid visitnum lasitcd lastresc; > > *run*; > > > > *proc* *sql*; > > select distinct LASTRESC into :p1 separated by ',' from la11 wherevisi= tnum eq > 1; > > select distinct LASTRESC into :p2 separated by ',' from la11 wherevisi= tnum eq > 222;...

Re: Converting Macro Variable to a SAS Dataset Variable #3
Send mail to the list not a person on the list! data visit1; set la11; if visitnum=1; lastresc1=lastresc; keep subjid lastresc1; run; data visit222; set la11; if visitnum=222; lastresc222=lastresc keep subjid lastresc222; run; data visit777; set la11; if visitnum=777; lastresc777=lastresc; keep subjid lastresc777; run; data new; merge visit1 visit222 visit777; by subjid; run; Proc Transpose could also be used on your first data set to flip it. -Mary ----- Original Message ----- From: Siddharth Jain To: Mary Sent: Wednesday, March 18, 2009 10:59 AM Subject: RE: Converting Macro Variable to a SAS Dataset Variable Hello Mary, Thanks for your response. Below is the code I have up till now: Per subjid per visit per organ code, I have to see whether result is changing or not. Thanks, Siddharth data la11; set la; if lacat in ('NTL') and subjid in ('101-001'); keep subjid visitnum lasitcd lastresc; run; proc sql; select distinct LASTRESC into :p1 separated by ',' from la11 where visitnum eq 1; select distinct LASTRESC into :p2 separated by ',' from la11 where visitnum eq 222; select distinct LASTRESC into :p3 separated by ',' from la11 where visitnum eq 777; %put <<p1>> &p1 <<p2>> &p2 <<p3> &p3; From: Mary [mailto:mlhoward@avalon.net] Sent: Wednesday, March 18, 2009 11:54 AM To: Siddharth Jain; SAS-L@LISTSERV.UGA.EDU Subject: Re: Converting Macro Variable t...

Re: Converting Macro Variable to a SAS Dataset Variable #2
Sounds like you should address this at the step where you create the macro variable; instead of creating a macro variable, create a dataset (or a dataset variable). (I assume this is related to your other query, which indicates that you create this macro variable in PROC SQL). Can you post some code and sample data for how you arrive at &p1 in the first place? -Joe On Wed, Mar 18, 2009 at 10:22 AM, Siddharth Jain <sjain@aveopharma.com>wrote: > If I have a macro variable p1 where %put <<p1>>; results in <<p1>> > 01,02,03,06 > > > How do I bring value of p1 to a dataset. Can I make a dataset variable > which > has the same values as of p1. > > > Thanks in advance for your help, > Siddharth > ...

Converting Macro Variable to a SAS Dataset Variable
If I have a macro variable p1 where %put <<p1>>; results in <<p1>> 01,02,03,06 How do I bring value of p1 to a dataset. Can I make a dataset variable which has the same values as of p1. Thanks in advance for your help, Siddharth ...

Re: SAS Intrnet question, passing macro variables to SAS.
Jia, You have to mask tokens that appear in pairs. In your example precede the single quote (') with a % sign. Try: &libdata=test&citystate=%str(%'Birmingham, AL%',%'Dothan, AL%',%'Huntsville,AL%') Nikhil Sardesai -----Original Message----- From: Michael L. Davis [mailto:michael@BASSETTCONSULTING.COM] Sent: Friday, January 28, 2005 5:13 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: [SAS-L] SAS Intrnet question, passing macro variables to SAS. Hello Jia and other SAS-L Friends, I'm not sure I know the answer but I have some ideas. However, first, I have a question. Are you building the URL outside of an HTML form? If you are, the following link on the SAS web site might interest you: http://support.sas.com/faq/039/FAQ03925.html You might also want to look at the following link: http://support.sas.com/rnd/web/intrnet/dispatch82/input.html Look at the section titled "Specifying Name/Value Pairs in a URL". Most likely, the ampersands might be playing a role. SAS/IntrNet strips off "unsafe characters" unless you tell it not to do so. Please see: http://support.sas.com/rnd/web/intrnet/dispatch82/srvusaf.html Part of that link states: The APPSRV_UNSAFE function returns the complete, original value of an input name/value pair. Normally unsafe characters (see the UNSAFE option) are stripped from input values before creating the input macro variables. This is done so that macro variables may be freely used in a a...

Re: urgent : Convert SAS array in to sas variables #2
On Sat, 3 May 2008 23:34:44 -0700, Shailesh <shailesh.tewari@GMAIL.COM> wrote: >In my dataset I have an array variable , say A which has values like >Observation 1 - A[1]= 23 ,A[2]=34, A[3]=45 >Observation 2 - A[11]= 23 ,A[12]=34, A[13]=45 > >I want to create sas variables which should have name A61, A62 , A63, >A64 .......... >Similarly for second observation these would be A71, A72, >A73 , A74......... > > >in the same datastep. > >Any help ? > >Regards, >Shailesh Arrays are DATA *step* structures. They do not exists in data *...

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...

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 #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: 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...

urgent : Convert SAS array in to sas variables
In my dataset I have an array variable , say A which has values like Observation 1 - A[1]= 23 ,A[2]=34, A[3]=45 Observation 2 - A[11]= 23 ,A[12]=34, A[13]=45 I want to create sas variables which should have name A61, A62 , A63, A64 .......... Similarly for second observation these would be A71, A72, A73 , A74......... in the same datastep. Any help ? Regards, Shailesh On May 4, 2:34=A0am, Shailesh <shailesh.tew...@gmail.com> wrote: > In my dataset I have an array variable , say A which has values like > Observation 1 - A[1]=3D 23 ,A[2]=3D34, A[3]=3D45 > Observati...

Re: Converting variables with SAS
Hi Knuako. The variable (column) 't' can only be one type - character OR numeric, but not both. In this case it appears to be a character variable since it has non-numeric values. So, I am a bit confused about your first question. If the different EFFECTS (I, t) came from different datasets that were set together, you would have recieved an error message indicating that the variable 't' is defined as both character and numeric, at which point you would have to do something about it. One solution would be to: 1. rename the variable 't' in the SET step in the input da...

RE : Re: SAS 9: How to send macro variable to autosignon remote
Hi Bob, It works if you just want to show the value by a %put statement. However, it doesn't work if you want to use the value in another statement on the remote session. For example: options autosignon=YES sascmd="sas -dmr -nonews -noterminal -nosyntaxcheck -rsasuser"; %let local_var=Hello; /* Start a few sessions (wait=yes) */ rsubmit TASK1 wait=yes; endrsubmit; %syslput remote_var=&local_var; rsubmit TASK2 wait=yes; endrsubmit; %syslput remote_var=&local_var; /* Run some parallel code (wait=no) */ rsubmit TASK1 wait=no; %put In task1 remote_var=&remo...

Re: SAS Macro to delete a SAS dataset 196997
> From: SAS Techies > Subject: SAS Macro to delete a SAS dataset > > Here's a simple SAS Macro to delete a SAS dataset...It takes the name of > the SAS dataset as the parameter... > > %macro deletedsn(dsname); > > %if %index(&dsname,'.') eq 0 %then %do; %let lib=work; %let > dsn=&dsname; %end; > %else %if %index(&dsname,'.') eq 0 %then %do; %let lib=%scan(&dsname, > 1,'.'); %let dsn=%scan(&dsname,1,'.'); %end; > > proc datasets lib=&lib nolist; > delete &dsn; > qui...

Re: converting sas transport files into sas datasets
Once you have assigned an xport libname you can read it in like a normal dataset. libname out xport 'C:\Documents and Settings\kdt\Desktop\class.xpt'; *- Create xport file; data out.class; set sashelp.class; run; *- Create work file from xport file; data work.class; set out.class; run; 2008/12/17 <pramila.sami@gmail.com>: > Hello All, > > Could anyone please give me the code for converting sas transport > files into sas datasets. thanks in advance. > ...

Re: SAS Global Macro Variables
Commands in autoexec.sas are read whenever SAS is started.You can put this in the root directory or elsewhere if you specify its location in the SAS startup command. However, if you need to change these often or you want to make it more evident to people reading you programs that these macros are being created, perhaps it may be preferrable to place all these commnads in a file you reference with %include at the top of every program. Scott Bucher SAS Programmer Office of Accountability NYC Dept. of Education -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] ...

Help needed to Concatenate variables in SAS Dataset into a new variable
Hi I have a SAS dataset with variables COL1, COL2 etc. The number of these can vary. I want to concatenate all of then into a new COL variable. Can you help. On Apr 1, 1:19=A0am, Bala <bsu...@gmail.com> wrote: > Hi > > I have a SAS dataset with variables COL1, COL2 etc. The number of > these can vary. > > I want to concatenate all of then into a new COL variable. > > Can you help. Check out cat(), cats(), catt() and catx() in the documentation. One of these functions will likely get the job done. Cheers, Alex col=cats(of col:); cats() will 'cut off' both leading and trailing blanks. Look up the different cat functions in case you need it different. ...

Re: Using the value of a SAS variable to select another variable
> From: myself > Subject: Re: Using the value of a SAS variable to select > another variable > > Hello again, > > I am now running into the 'reverse' problem, namely:, keeping > with my previous example, with the fields V1, P1, P2 and P3, > I need my code to do this, depending on the value in the > field V1 > If V1=1 then assign new values (which I calculate) > to the variables P2 and P3, > If V1=2 then assign new value to > P3 and so on. ah, this does not read as systematic > Again, I have more than just 3 fields P's I have 38 >...

Re: SAS Macro to delete a SAS dataset #2 313487
I too like(d) PROC DELETE. When I used it I was forced to remove it and use PROC DATASETS because PROC DELETE is not documented. Also, but I have not tested it. How does it work with indexed data sets, audit trails, generation data groups, views, etc.? I don't worry much about deleting, "all" of my programs run in batch and are obsolete as soon as they are written. On 12/3/09, Fehd, Ronald J. (CDC/CCHIS/NCPHI) <rjf2@cdc.gov> wrote: > > From: SAS Techies > > Subject: SAS Macro to delete a SAS dataset > > > > Here's a simple SAS...

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: counting the number of variables a SAS dataset
Hello Massi... Using the DICTIONARY library you could easily extract whatever = information you need... Examine the following: proc SQL noprint; create table list1 as select * from DICTIONARY.TABLES =20 where LibName eq upcase("YOUR_LIB") and memname =3D "YOUR_SAS_DATASET"; quit; You'll find a bunch of usefull information as well... Have fun... Patrice Bourdages Information System Analyst Industrial Alliance, home and car insurance -----Message d'origine----- De : fuzzy_fi@EXCITE.IT [mailto:fuzzy...

Re: question about sas macro variables #4
On 1/16/09, karma <dorjetarap@googlemail.com> wrote: > I think this raises another interesting question, can SAS macro create > macro code that is executable at a later time? As far as I know, Lisp > allows macro code to create macro code ad infinitum. I don't think SAS > does allow this, but I would be happy to be proven wrong on this. An > example: > > %let c = %superq(%put 1;); > %unquote(c); This doesn't work because SUPERQ only works on macro variables and the unquote is missing & for &C. But it can be made to work see lines 1 and 2 below. ...

Re: Ordering Variables in SAS Dataset #2
The SET and RETAIN statements are in the wrong order. On Thu, Mar 20, 2008 at 8:02 AM, DaDoctor <brett.a.summers@bankofamerica.com> wrote: > Fellow Members: > > I am working ordering a SAS dataset and thought I could use the retain > statement for this purpose. > > However, the process is bombing. > > syntax: > > data temp_dset; > set out.perm_dset; > retain var1 var2.........; > > run; > > > suggestions on what I am doing wrong? > ...

Web resources about - Re: Converting Macro Variable to a SAS Dataset Variable - comp.soft-sys.sas

PastBook’s Filepicker.io Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.


"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Converting dry air to water: solution to Broken Hill's water crisis gains support
A one-man crusade by a Broken Hill resident to solve the historic town's water crisis by introducing air to water converters is gaining support. ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Resources last updated: 3/16/2016 9:47:00 AM